Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to use different private key files to connect to different SSH servers (ssh://git-server:port/repository). How to manage that? SSH seems to assume the private key file in ~/.ssh/id_rsa.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

That's why there's the -i option:

-i identity_file

Selects a file from which the identity (private key) for RSA or DSA authentication is read. The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for protocol version 2.

Identity files may also be specified on a per-host basis in the configuration file. It is possible to have multiple -i options (and multiple identities specified in configuration files).

If you want to make this permanent, you need to setup your SSH config file and set the according IdentityFile option.

IdentityFile

Specifies a file from which the user's DSA, ECDSA or DSA authentication identity is read. […]

If you see a dialog similar to this:

enter image description here

You need to enter your user password for your OS X account. Not your key passphrase, or the remote SSH password. This is because they identity hasn't been stored in the keychain.

According to this tutorial, the following command should add them appropriately:

ssh-add -K
share|improve this answer
    
OK, I've done that now, but when trying to log in, OS X asks in a separate dialog for the password instead of passphrase. I'm entering the correct passphrase for the private key files, but it still can't log in. Any further ideas? –  Mike L. Nov 22 '11 at 15:29
    
If it asks you for the password, that's the SSH password on the remote machine, not the passphrase for the key. –  slhck Nov 22 '11 at 15:32
    
No, no, it asks me for the password for my private key file - at least that's what the dialog is saying. BTW, without the passphrase SSH could not do anything on the remote machine. –  Mike L. Nov 22 '11 at 15:49
    
Hm. I'm not an expert in SSH, I have to admit. What is that dialog saying exactly? –  slhck Nov 22 '11 at 15:59
    
I've configured IdentityFile = ~/secret/pk-file in ~/.ssh/config and invoke ssh myserver. The occurring dialog says Enter your password for the SSH key "pk-file"., shows a Password input field and two checkboxes (Show password and Remember passwod in my keychain). I'm entering the correct passphrase, but I'm asked 2 more times and then SSH aborts with RSA host key for IP address '1.2.3.4' not in list of known hosts. Permission denied (publickey). (1.2.3.4 is dummy). –  Mike L. Nov 23 '11 at 8:34
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.