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

Lets say that my user name of my mac machine is John.

I have a fully configured slicehost account. Note that on this slice there is no ssh key for John.

Now I configure this box for ssh acces for user deploy.

On my mac machine I have the private key for user deploy. Slicehost has public key for user deploy.

Again slicehost has nothing for user john.

If I want to ssh into sliceghost box as user deploy do I need to put the public key for John there too?

share|improve this question
    
For the sake of completness I would add this link so that I can refer to it later. gist.github.com/df7d13a0556cd4a1bc13 –  user35340 Feb 18 '10 at 21:13

3 Answers 3

up vote 7 down vote accepted

Sort of.

You need to put your public key for the account you're coming from on the remote server. If that is your John key, then put that key on the server that you are connecting to using the appropriate account for that server.

In your case, you're connecting as deploy. So, when you connect, you'll type:

ssh deploy@slicehost

If your key for John is in the .ssh/authorized_keys file of the account deploy, then you'll get direct access.

share|improve this answer
1  
doesn't that defeat the whole purpose of logging in as someone else. So in this case it seems I need to put public key for both John and deploy in the authorized_keys file. –  user35340 Feb 18 '10 at 20:38
1  
No. We do this all the time for sftp backups. We generate a public private key pair on which ever system we need to back up. The we put the public key for that account/machine on our backup server under a user, backup-user, for instance. Then to backup from the client machine we sftp to backup-user@backup_machine. The user on the client machine doesn't matter. It just matters that a public key for that machine is in the authorized_keys file on the backup server under the backup-user account's .ssh directory. Works like a charm. –  Jim Feb 18 '10 at 20:43

No. The username has nothing to do with the public/private key pair. It's not recorded anywhere in either key. So long as you place the public key in a user's .ssh/authorized_keys file you can log in as that user by using the private key.

share|improve this answer
    
Just trying to make sure that I understand correctly. As long as John has the private key for deploy and the public key for deploy is in the authorized_keys file , John should be able to login as deploy. –  user35340 Feb 18 '10 at 20:40

You will need to specify both that you want to log in as user "deploy" and also specify the identity file for deploy.

ssh -i ~/.ssh/id_deploy.rsa deploy@slicehost

Where id_deploy.rsa is the private key file corresponding to the authorized key you uploaded to the slicehost account.

share|improve this answer

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.