How to tell Finder where to find private key when "Connect to Server" using SSH?
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
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
You have to add your public key (e.g. ~/.ssh/id_rsa.pub) to the authorized_keys file on the server. If you have no key/public key create one with:
ssh-keygen -t rsa -b 4096 -C "user@host" #-C "user@host" is an optional comment
If you have no access to the server you have to provide the public key to an admin and ask him to add it to the authorized_keys file on the server.
Creating a config file as proposed in rwenz3l's answer is not required when you didn't enter a passphrase for the rsa key.