mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-31 22:36:41 -04:00
Simplify target existence checks
This commit is contained in:
+4
-4
@@ -18,12 +18,12 @@ import (
|
||||
func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][3]string, rcwPassphrase []byte, preserveOldConfigDir bool) error {
|
||||
r := strings.ToLower(inputCB("Configure SSH settings (for synchronization)? (y/N)"))
|
||||
if len(r) > 0 && r[0] == 'y' {
|
||||
// ensure ssh key file exists
|
||||
// ensure ssh key file exists (and is a file)
|
||||
fallbackSSHKey := back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "id_ed25519"
|
||||
sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB(back.AnsiBold+"Note:"+back.AnsiReset+" Only key-based authentication is supported (keys may optionally be passphrase-protected).\n The remote server must already be in your ~"+global.PathSeparator+".ssh"+global.PathSeparator+"known_hosts file.\n\nSSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey)
|
||||
sshKeyIsFile, _, _ := back.TargetIsFile(sshKeyPath, false, 0) // error is ignored because errorOnFail is false
|
||||
if !sshKeyIsFile {
|
||||
return errors.New("SSH identity file not found: " + sshKeyPath)
|
||||
_, err := back.TargetIsFile(sshKeyPath, true)
|
||||
if err != nil {
|
||||
return errors.New("unable to find SSH identity file: " + err.Error())
|
||||
}
|
||||
|
||||
// get other ssh info from user
|
||||
|
||||
Reference in New Issue
Block a user