chore: home
This commit is contained in:
3
main.go
3
main.go
@@ -46,13 +46,13 @@ func main() {
|
||||
}
|
||||
|
||||
ssh.Handle(func(s ssh.Session) {
|
||||
// authorizedKey := gossh.MarshalAuthorizedKey(s.PublicKey())
|
||||
io.WriteString(s, WELCOME)
|
||||
|
||||
cmd := exec.Command("/bin/bash")
|
||||
ptyReq, winCh, isPty := s.Pty()
|
||||
if isPty {
|
||||
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)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -67,6 +67,7 @@ func main() {
|
||||
}()
|
||||
io.Copy(s, f) // stdout
|
||||
cmd.Wait()
|
||||
s.Exit(0)
|
||||
} else {
|
||||
io.WriteString(s, "No PTY requested.\n")
|
||||
s.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user