ssh_config
ssh_config copied to clipboard
Expected behavior when no config files exist
What is the expected behavior when neither of the identity files exist?
It seems that the NonExist errors are ignored and a default value is returned.
I'm trying to build some auth with fallback and the lack of error means I have to be aware of what files you are checking and make sure they don't exist.
From https://pkg.go.dev/github.com/kevinburke/ssh_config#GetStrict
The returned error will be non-nil if and only if a user's configuration file or the system configuration file could not be parsed, and u.IgnoreErrors is false.
I would expect that if neither file is found, then it should "fail to parse" and I would get an error.
Could we add some logic to https://github.com/kevinburke/ssh_config/blob/v1.1.0/config.go#L247 to return an error when both methods fail to find a file to parse?
Just hit this issue:
open ~/.ssh/identity: no such file or directory
Since I'm not so familiar with the library, what would you recommend instead of this: ssh_config.Get(host, "IdentityFile")
?
The following simply works:
ssh -F ./my-ssh-config my-user
$ cat my-ssh-config
Host colima
IdentityFile "/Users/furkan/.lima/_config/user"
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
NoHostAuthenticationForLocalhost yes
GSSAPIAuthentication no
PreferredAuthentications publickey
Compression no
BatchMode yes
IdentitiesOnly yes
Ciphers "^[email protected],[email protected]"
User lima
ControlMaster auto
ControlPath "/Users/furkan/.lima/colima/ssh.sock"
ControlPersist 5m
ForwardAgent yes
Hostname 127.0.0.1
Port 52253
cc @kevinburke