Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In /home/petri/.ssh/ I have my private key called petri. When I try to connect to my server using ssh, it does not accept my private key. Running -v learns that it is not trying my key petry, but just the non-existent id_rsa and id_dsa:

$ssh server
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: petri@office
debug1: Authentications that can continue: publickey
debug1: Offering public key: petri@office
debug1: Authentications that can continue: publickey
debug1: Offering public key: petri@office
debug1: Authentications that can continue: publickey
debug1: Offering public key: petri@office
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/petri/.ssh/id_rsa
debug1: Trying private key: /home/petri/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

The odd thing is that things were fine before. Anyway, how do I tell SSH to use my petri key and quite trying the non-existent standard keys?

NOTE: my .ssh folder is chmod 700 and the petri file is 600, that is not the problem.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Two ways:

  1. Specify the key in your ssh command, something like "ssh -i ~/.ssh/petri server.example.com"

  2. Create a .ssh/config file with something like:

Host *

IdentityFile /home/petri/.ssh/petri

For more options, do a "man ssh_config" or "man ssh", depending on which you want to do.

share|improve this answer
    
3. Rename the private key to something standard and save yourself lots of trouble. –  Alex Holst Aug 16 '11 at 16:35
1  
Yes, I would do the rename if that's the only key you're using. If you use multiple keys, use a bunch of Host entries in ~/.ssh/config. If it's a one-off connection, use the "-i" option for the ssh command. –  cjc Aug 16 '11 at 16:37
    
@Alex Holst: I have also other keys to install and prefer to differentiate them with easy names. –  user60129 Aug 16 '11 at 16:47
    
I'm curious. Why do you have multiple private keys on one system? I have one at home and one at work. –  Alex Holst Aug 16 '11 at 17:21

Try this:

ssh -i /path/to/petri
share|improve this answer

Your Answer

 
discard

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