Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.ssh/config: "Bad configuration option: UseKeychain" on Mac OS Sierra 10.12.6

I am trying to set up my ssh config on the Mac (Mac OS Sierra 10.12.6) in such a way that it stores the passphrase for my ssh key in the keychain. Previously I could do that with

ssh-add -K ~/.ssh/id_rsa

But recently this doesn't seem to work anymore. Following this article there seems to be a change in the behaviour of the ssh config in Mac OS > 10.12.2 and the recommended way to fix this issue is to add UseKeychain yes to your ssh config. So here's my .ssh/config section the Host *:

Host *
  Port 22
  ServerAliveInterval 60
  ForwardAgent yes
  IdentityFile ~/.ssh/id_rsa
  AddKeysToAgent yes
  UseKeychain yes

When trying to ssh to a foreign host, I get the following error message:

$ ssh my-host
/Users/USER/.ssh/config: line 16: Bad configuration option: usekeychain

Any ideas why this happens and how I can fix it? Thanks!

like image 209
Michael Lihs Avatar asked Sep 26 '22 01:09

Michael Lihs


People also ask

Where is SSH config file on Mac?

Where is the SSH configuration file? On macOS systems, the configuration file is found at “/private/etc/ssh/ssh_config,” which is symlinked to “/etc/ssh/ssh_config” for compatibility.

How do I access SSH config?

The ssh program on a host receives its configuration from either the command line or from configuration files ~/. ssh/config and /etc/ssh/ssh_config . Command-line options take precedence over configuration files. The user-specific configuration file ~/.


1 Answers

Try to specify another option, namely IgnoreUnknown like below:

Host *
  IgnoreUnknown UseKeychain
  UseKeychain yes

You can find more info about this here.

If you already have an IgnoreUnknown value, use comma separated values

Host *
  IgnoreUnknown AddKeysToAgent,UseKeychain
  AddKeysToAgent yes
  UseKeychain yes

If you have multiple Host configs that use the UseKeychain option, make sure to put

Host *
  IgnoreUnknown UseKeychain

before the first host that uses the the option, e.g. put it at the top of the file.

If you do not want to (or cannot) modify your SSH configuration file, you can also pass this option when connecting on the command line:

ssh -o IgnoreUnknown=UseKeychain my-host
like image 339
mic4ael Avatar answered Oct 11 '22 11:10

mic4ael