Search code examples
macosssh-keysssh-keygen

ssh key not working on mac machines


I already have the id_rsa keys inside my .ssh file (with passphrase)

Now, I would like to add new key so that I could connect to the server with ssh without password.

I do it like:

ssh-keygen -t rsa
>> /Users/markoz/.ssh/id_rsa_new
>> Passphrase:

now I have both keys inside .ssh folder

.ssh $ ls
id_rsa    id_rsa.pub    id_rsa_new    id_rsa_new.pub    known_hosts

Now if I copy the id_rsa_new.pub key into server authorized_keys, it doesn't work (it ask me for password)

But if I copy key of the id_rsa.pub key into server authorized_keys it works (ask for passphrase)

Did I miss something? Is there a rule that only one kew can be used?


Solution

  • By default ssh takes ~/.ssh/id_rsa key. You should specify it explicitly if different - use $ ssh -i ~/.ssh/id_rsa_new host, for example.