grim/hgkeeper

a8f2ce6d6411
Parents 8f70636bb8a3
Children fb15a51fc845
Show a message when trying to log in with a shell
--- a/ssh/server.go Wed Sep 18 09:28:19 2019 -0500
+++ b/ssh/server.go Wed Sep 18 09:31:31 2019 -0500
@@ -1,6 +1,8 @@
package ssh
import (
+ "fmt"
+
"github.com/gliderlabs/ssh"
log "github.com/sirupsen/logrus"
gossh "golang.org/x/crypto/ssh"
@@ -55,14 +57,15 @@
}
func (s *Server) sessionHandler(session ssh.Session) {
+ username := session.Context().Value("username").(string)
+
// per the docs, session.Command is empty if the user is requesting a shell.
// we only support execs, which means command should be non-empty.
if len(session.Command()) == 0 {
+ fmt.Fprintf(session, "logged in as %s\n\nShell access is disabled\n", username)
return
}
- username := session.Context().Value("username").(string)
-
log.Infof(
"%s@%s requested command %q",
username,