HandleTailscaleSSHConn handles an incoming TCP connection as an SSH session. Authentication is not required — the WireGuard tunnel provides identity. The connection is served using the gliderlabs/ssh library with a single ed25519 host key generated on first use in ~/.config/tailcat/ssh/. Two modes
(c net.Conn)
| 44 | // via the user's shell with "-c"; otherwise an interactive login shell is |
| 45 | // started with a PTY. |
| 46 | func (s *Server) HandleTailscaleSSHConn(c net.Conn) { |
| 47 | keys, err := getHostKeys() |
| 48 | if err != nil { |
| 49 | s.lb.logf("SSH host keys: %v", err) |
| 50 | c.Close() |
| 51 | return |
| 52 | } |
| 53 | srv := &ssh.Server{ |
| 54 | Handler: sessionHandler, |
| 55 | NoClientAuthHandler: func(ctx ssh.Context) error { return nil }, |
| 56 | ChannelHandlers: map[string]ssh.ChannelHandler{"session": ssh.DefaultSessionHandler}, |
| 57 | RequestHandlers: map[string]ssh.RequestHandler{}, |
| 58 | SubsystemHandlers: map[string]ssh.SubsystemHandler{}, |
| 59 | } |
| 60 | for _, k := range keys { |
| 61 | srv.AddHostKey(k) |
| 62 | } |
| 63 | srv.HandleConn(c) |
| 64 | } |
| 65 | |
| 66 | // sessionHandler handles a single SSH session (shell or exec). |
| 67 | func sessionHandler(sess ssh.Session) { |
nothing calls this directly
no test coverage detected