cmd/ssh-auth-none-demo: update SSH demo a bit
Per chat with an SSH client author who wanted a URL in the output. And then make it more clear what parts are banners. Updates #cleanup Change-Id: If5033ad9dc0dba3d833f24ea39e117a455010492 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
3f5eb31997
commit
dfb605db4a
@@ -86,19 +86,20 @@ func main() {
|
||||
if cm.User() == "banners" {
|
||||
totalBanners = 5
|
||||
}
|
||||
|
||||
for banner := 2; banner <= totalBanners; banner++ {
|
||||
time.Sleep(time.Second)
|
||||
if banner == totalBanners {
|
||||
spac.SendAuthBanner(fmt.Sprintf("# Banner%d: access granted at %v\r\n", banner, time.Since(start)))
|
||||
spac.SendAuthBanner(fmt.Sprintf("# Final banner saying access granted (+%v)\r\n", time.Since(start).Round(time.Millisecond)))
|
||||
} else {
|
||||
spac.SendAuthBanner(fmt.Sprintf("# Banner%d at %v\r\n", banner, time.Since(start)))
|
||||
spac.SendAuthBanner(fmt.Sprintf("# Another banner saying we're still waiting for auth server-side (+%v)\r\n", time.Since(start).Round(time.Millisecond)))
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
},
|
||||
BannerCallback: func(cm ssh.ConnMetadata) string {
|
||||
log.Printf("Got connection from user %q, %q from %v", cm.User(), cm.ClientVersion(), cm.RemoteAddr())
|
||||
return fmt.Sprintf("# Banner for user %q, %q\n", cm.User(), cm.ClientVersion())
|
||||
return fmt.Sprintf("# Example URL in auth bannner for %q, %q: https://github.com/tailscale/tailscale\r\n", cm.User(), cm.ClientVersion())
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -136,6 +137,8 @@ func handleSessionPostSSHAuth(s gliderssh.Session) {
|
||||
}
|
||||
}()
|
||||
|
||||
fmt.Fprintf(s, "We're past auth phase now. Goodbye in ...\n")
|
||||
|
||||
for i := 10; i > 0; i-- {
|
||||
fmt.Fprintf(s, "%v ...\n", i)
|
||||
time.Sleep(time.Second)
|
||||
|
||||
Reference in New Issue
Block a user