diff --git a/client/ssh/server/command_execution_unix.go b/client/ssh/server/command_execution_unix.go index 970f31c6c..2b9db863b 100644 --- a/client/ssh/server/command_execution_unix.go +++ b/client/ssh/server/command_execution_unix.go @@ -98,9 +98,6 @@ func (pm *ptyManager) File() *os.File { } func (s *Server) handlePty(logger *log.Entry, session ssh.Session, privilegeResult PrivilegeCheckResult, ptyReq ssh.Pty, winCh <-chan ssh.Window) bool { - cmd := session.Command() - logger.Infof("executing Pty command: %s", safeLogCommand(cmd)) - execCmd, err := s.createPtyCommand(privilegeResult, ptyReq, session) if err != nil { logger.Errorf("Pty command creation failed: %v", err) @@ -114,6 +111,14 @@ func (s *Server) handlePty(logger *log.Entry, session ssh.Session, privilegeResu return false } + shell := execCmd.Path + cmd := session.Command() + if len(cmd) == 0 { + logger.Infof("starting interactive shell: %s", shell) + } else { + logger.Infof("executing command: %s", safeLogCommand(cmd)) + } + ptmx, err := s.startPtyCommandWithSize(execCmd, ptyReq) if err != nil { logger.Errorf("Pty start failed: %v", err) diff --git a/client/ssh/server/command_execution_windows.go b/client/ssh/server/command_execution_windows.go index 56803f6d5..c646c36b8 100644 --- a/client/ssh/server/command_execution_windows.go +++ b/client/ssh/server/command_execution_windows.go @@ -267,7 +267,13 @@ func (s *Server) prepareCommandEnv(localUser *user.User, session ssh.Session) [] func (s *Server) handlePty(logger *log.Entry, session ssh.Session, privilegeResult PrivilegeCheckResult, ptyReq ssh.Pty, winCh <-chan ssh.Window) bool { cmd := session.Command() - logger.Infof("executing Pty command: %s", safeLogCommand(cmd)) + shell := getUserShell(privilegeResult.User.Uid) + + if len(cmd) == 0 { + logger.Infof("starting interactive shell: %s", shell) + } else { + logger.Infof("executing command: %s", safeLogCommand(cmd)) + } // Always use user switching on Windows - no direct execution s.handlePtyWithUserSwitching(logger, session, privilegeResult, ptyReq, winCh, cmd) diff --git a/client/ssh/server/server.go b/client/ssh/server/server.go index a17283ef5..39899352a 100644 --- a/client/ssh/server/server.go +++ b/client/ssh/server/server.go @@ -528,7 +528,7 @@ func (s *Server) connectionValidator(_ ssh.Context, conn net.Conn) net.Conn { return nil } - log.Infof("SSH connection from NetBird peer %s allowed", remoteIP) + log.Infof("SSH connection from NetBird peer %s allowed", tcpAddr) return conn }