Skip to content

Instantly share code, notes, and snippets.

@joshrendek
Created July 8, 2014 03:01
Show Gist options
  • Save joshrendek/a64c073b610e35623b23 to your computer and use it in GitHub Desktop.
Save joshrendek/a64c073b610e35623b23 to your computer and use it in GitHub Desktop.
func HandleShellRequest(channel ssh.Channel, in <-chan *ssh.Request) {
for req := range in {
ok := true
logfile.Println("[request " + req.Type + "]: " + string(req.Payload))
switch req.Type {
case "shell":
logfile.Println("[shell]")
case "exec":
if string(req.Payload) == "uname" {
logfile.Println("[[[" + string(req.Payload) + "]]]")
channel.Write([]byte("\n\rLinux\n\r"))
}
channel.Close()
}
req.Reply(ok, nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment