1
0
Fork 0
forked from External/grumble

Refine auto-keypair regen functionality. Complain loudly if only one of (cert.pem, key.pem) exists.

This commit is contained in:
Mikkel Krautz 2011-11-10 13:17:18 +01:00
parent 76747e0b71
commit b94b04d2de
4 changed files with 67 additions and 42 deletions

54
ssh.go
View file

@ -72,7 +72,7 @@ func RunSSH() {
"<id> <key> <value>",
"Get a config value for the server with the given id")
pemBytes, err := ioutil.ReadFile(filepath.Join(Args.DataDir, "key"))
pemBytes, err := ioutil.ReadFile(filepath.Join(Args.DataDir, "key.pem"))
if err != nil {
log.Fatal(err)
}
@ -89,32 +89,34 @@ func RunSSH() {
log.Printf("Listening for SSH connections on '%v'", Args.SshAddr)
for {
conn, err := listener.Accept()
if err != nil {
log.Fatalf("ssh: unable to accept incoming connection: %v", err)
}
err = conn.Handshake()
if err == io.EOF {
continue
} else if err != nil {
log.Fatalf("ssh: unable to perform handshake: %v", err)
}
go func() {
for {
channel, err := conn.Accept()
if err == io.EOF {
return
} else if err != nil {
log.Fatalf("ssh: unable to accept channel: %v", err)
}
go handleChannel(channel)
go func() {
for {
conn, err := listener.Accept()
if err != nil {
log.Fatalf("ssh: unable to accept incoming connection: %v", err)
}
}()
}
err = conn.Handshake()
if err == io.EOF {
continue
} else if err != nil {
log.Fatalf("ssh: unable to perform handshake: %v", err)
}
go func() {
for {
channel, err := conn.Accept()
if err == io.EOF {
return
} else if err != nil {
log.Fatalf("ssh: unable to accept channel: %v", err)
}
go handleChannel(channel)
}
}()
}
}()
}
func handleChannel(channel ssh.Channel) {