INNER CODE UNIT · Go
sshKey
umputun/spot · cmd/spot/main.go:484
func sshKey(sshAgent bool, sshKey string, pbook *config.PlayBook) (key string, err error) {
if sshKey == "" && !sshAgent && pbook != nil && pbook.SSHKey != "" { // no key provided in cli and not using agent
sshKey = pbook.SSHKey // use playbook's ssh_key
}
if p, err := expandPath(sshKey); err == nil {
sshKey = p
}
if sshKey == "" { // no key provided in cli or playbook
u, err := userProvider.Current()
if err != nil {
return "", fmt.Errorf("can't get current user: %w", err)
}
if !sshAgent {
sshKey = filepath.Join(u.HomeDir, ".ssh", "id_rsa")
}
}