Jeel
Jeel

Reputation: 2525

SSH to another host via different user

I need to SCP some files without password. I am confusing myself over the SSH authentication.Below is the scenario

Host: server1 User: user1 (Has access on server1)

Host: server2 user: user2 (Has access on server2)

So how do I setup the ssh handshake between the two users and on which server?

Upvotes: 1

Views: 3829

Answers (1)

drew010
drew010

Reputation: 69927

You just need to push your keys for the user on the client (doing the copying) to the user account on the host (receiving the files).

So if you want server2's user2 to copy to user1 on server1:

# logged in as user2 on server2
ssh-copy-id user1@server1

Or the other way around:

# logged in as user1 on server1
ssh-copy-id user2@server2

Enter your password when prompted, the keys should then be copied.

Then you can test:

ssh user1@server1 # should log in with no password to server1 as user1

Upvotes: 3

Related Questions