13

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?

1

3 Answers 3

22

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.

2
  • 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
    Commented Feb 18, 2010 at 20:38
  • 3
    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
    Commented Feb 18, 2010 at 20:43
1

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.

2
  • 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
    Commented Feb 18, 2010 at 20:40
  • That doesn't seem to work for my - I copied the .ssh.authorized_keys from one account to the other but still canot log in
    – Edgar H
    Commented Jun 26, 2019 at 10:06
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .