Improve SSH host key file not found error

This commit is contained in:
Trevor Slocum 2020-03-12 08:18:56 -07:00
parent 42c8f99304
commit 5074c6e607
2 changed files with 7 additions and 2 deletions

View file

@ -1,5 +1,6 @@
0.1.8:
- Add custom color support
- Improve SSH host key file not found error
0.1.7:
- Spawn pieces within view

View file

@ -114,9 +114,13 @@ func (s *SSHServer) Host(newPlayers chan<- *game.IncomingPlayer) {
},
}
err = server.SetOption(ssh.HostKeyFile(path.Join(homeDir, ".ssh", "id_rsa")))
hostKeyFile := path.Join(homeDir, ".ssh", "id_rsa")
if _, err = os.Stat(hostKeyFile); os.IsNotExist(err) {
log.Fatalf("failed to start SSH server: host key file %s not found\nto generate the missing key file, execute the following command:\nssh-keygen -t rsa -b 4096", hostKeyFile)
}
err = server.SetOption(ssh.HostKeyFile(hostKeyFile))
if err != nil {
log.Fatalf("failed to start SSH server: failed to set host key file: %s", err)
log.Fatalf("failed to start SSH server: failed to set host key file %s: %s", hostKeyFile, err)
}
go func() {