MacOS – How to tell Finder where to find private key when “Connect to Server” using SSH

findermacosNetworkssh

In Finder, using the Connect to Server option, I am able to specify the server I wish to connect to using ssh://user@server form (hostname or IP). However, the server I'm connecting to requires public key authentication, thus Finder,when I press the connect button, responds in a new window:

Permission denied (publickey)
[Process completed]

How do I configure Finder to be able to locate my private key in ~/.ssh?

macOS Sierra 10.12.3

Best Answer

Finder in macOS Sierra appears to only add the id_rsa key by default. If you want to add other keys you either have to add them manually or alter the configuration.

on my machine a simple ssh-add ~/.ssh/test.key worked.

According to this guide you can also store the keys in your keychain:

In ~/.ssh create config file with the following content:

Host * (asterisk for all hosts or add specific host)
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile <key> (e.g. ~/.ssh/userKey)

You can read more about this on the Apple Developer Site