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) {
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user