Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected behavior when no config files exist #34

Open
verdverm opened this issue Sep 1, 2021 · 1 comment
Open

Expected behavior when no config files exist #34

verdverm opened this issue Sep 1, 2021 · 1 comment

Comments

@verdverm
Copy link

verdverm commented Sep 1, 2021

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?

@Dentrax
Copy link

Dentrax commented Sep 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants