Monday 1 August 2016

Passwordless ssh between different users in a single command

There can many be situations wherein we login to a destination machine with a different username than the source machine.
To exchange ssh keys between different users is easy with the ssh-copy-id command.

In this example, I have users user1 & user2 on source & destination servers.
I've generated ssh keys for user1 on the source server. Now, I want to login to destination server as user2 without being prompted for a password.

To do this I need to run the command ssh-copy-id <destination user>@<destination server>


When we do this what happens is that on the destination server, the authorized_keys file for the destination user gets updated with the keys of the source user on source server:


No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...