Skip to content

Commit 576b4a7

Browse files
committed
Log shell
1 parent e6854df commit 576b4a7

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

client/ssh/server/command_execution_unix.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ func (pm *ptyManager) File() *os.File {
9898
}
9999

100100
func (s *Server) handlePty(logger *log.Entry, session ssh.Session, privilegeResult PrivilegeCheckResult, ptyReq ssh.Pty, winCh <-chan ssh.Window) bool {
101-
cmd := session.Command()
102-
logger.Infof("executing Pty command: %s", safeLogCommand(cmd))
103-
104101
execCmd, err := s.createPtyCommand(privilegeResult, ptyReq, session)
105102
if err != nil {
106103
logger.Errorf("Pty command creation failed: %v", err)
@@ -114,6 +111,14 @@ func (s *Server) handlePty(logger *log.Entry, session ssh.Session, privilegeResu
114111
return false
115112
}
116113

114+
shell := execCmd.Path
115+
cmd := session.Command()
116+
if len(cmd) == 0 {
117+
logger.Infof("starting interactive shell: %s", shell)
118+
} else {
119+
logger.Infof("executing command: %s", safeLogCommand(cmd))
120+
}
121+
117122
ptmx, err := s.startPtyCommandWithSize(execCmd, ptyReq)
118123
if err != nil {
119124
logger.Errorf("Pty start failed: %v", err)

client/ssh/server/command_execution_windows.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,13 @@ func (s *Server) prepareCommandEnv(localUser *user.User, session ssh.Session) []
267267

268268
func (s *Server) handlePty(logger *log.Entry, session ssh.Session, privilegeResult PrivilegeCheckResult, ptyReq ssh.Pty, winCh <-chan ssh.Window) bool {
269269
cmd := session.Command()
270-
logger.Infof("executing Pty command: %s", safeLogCommand(cmd))
270+
shell := getUserShell(privilegeResult.User.Uid)
271+
272+
if len(cmd) == 0 {
273+
logger.Infof("starting interactive shell: %s", shell)
274+
} else {
275+
logger.Infof("executing command: %s", safeLogCommand(cmd))
276+
}
271277

272278
// Always use user switching on Windows - no direct execution
273279
s.handlePtyWithUserSwitching(logger, session, privilegeResult, ptyReq, winCh, cmd)

client/ssh/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ func (s *Server) connectionValidator(_ ssh.Context, conn net.Conn) net.Conn {
528528
return nil
529529
}
530530

531-
log.Infof("SSH connection from NetBird peer %s allowed", remoteIP)
531+
log.Infof("SSH connection from NetBird peer %s allowed", tcpAddr)
532532
return conn
533533
}
534534

0 commit comments

Comments
 (0)