chore: home

This commit is contained in:
2021-07-18 23:21:13 +08:00
parent b69beb511d
commit 65991e53f3

View File

@@ -46,13 +46,13 @@ func main() {
} }
ssh.Handle(func(s ssh.Session) { ssh.Handle(func(s ssh.Session) {
// authorizedKey := gossh.MarshalAuthorizedKey(s.PublicKey())
io.WriteString(s, WELCOME) io.WriteString(s, WELCOME)
cmd := exec.Command("/bin/bash") cmd := exec.Command("/bin/bash")
ptyReq, winCh, isPty := s.Pty() ptyReq, winCh, isPty := s.Pty()
if isPty { if isPty {
cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", ptyReq.Term)) cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", ptyReq.Term))
cmd.Env = append(cmd.Env, fmt.Sprintf("HOME=/root"))
f, err := pty.Start(cmd) f, err := pty.Start(cmd)
if err != nil { if err != nil {
panic(err) panic(err)
@@ -67,6 +67,7 @@ func main() {
}() }()
io.Copy(s, f) // stdout io.Copy(s, f) // stdout
cmd.Wait() cmd.Wait()
s.Exit(0)
} else { } else {
io.WriteString(s, "No PTY requested.\n") io.WriteString(s, "No PTY requested.\n")
s.Exit(1) s.Exit(1)