MCPcopy Create free account
hub / github.com/tailscale/tailcat / HandleTailscaleSSHConn

Method HandleTailscaleSSHConn

tailcat_ssh.go:46–64  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

44// via the user's shell with "-c"; otherwise an interactive login shell is
45// started with a PTY.
46func (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).
67func sessionHandler(sess ssh.Session) {

Callers

nothing calls this directly

Calls 2

getHostKeysFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected