The Lumber Room

"Consign them to dust and damp by way of preserving them"

ssh-keygen as another user

with 4 comments

To set up an ssh-key usually, type
ssh-keygen -t rsa, hit [Enter] a few times, type
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys, and add entries from other places where you might have created a key, to the same authorized_keys.

To set it up so you can log in as another user (called, say, user2)
ssh-keygen -t rsa
Enter a different file to save (id_for_user2, say), and blank passphrase.
Now add the contents of the file id_for_user2.pub to user2‘s ~/.ssh/authorized_keys file.

Oh, and when you want to login as that user, you will have to specify that you want to use that file, like
ssh -i ~/.ssh/id_for_user2 user2@hostname. For long commands like this, it’s best to make an alias (put alias sshasuser2='ssh -i ~/.ssh/id_for_user2 user2@localhost' in your ~/.bashrc if all you want is a password-less replacement for su - user2). You can also give the id_for_user2 file to others, and they can also login as user2 without a password simply by typing the command above.

Got it from this linux.debian.user newsgroup post.

About these ads

Written by S

Thu, 2005-11-17 at 13:01:00 +05:30

4 Responses

Subscribe to comments with RSS.

  1. thanks very usefull

    Oliver

    Wed, 2008-01-23 at 21:46:29 +05:30

  2. Thanks..

    Joe

    Sat, 2008-12-20 at 02:19:11 +05:30

  3. Thanks it worked

    zafer

    Thu, 2010-11-04 at 16:23:29 +05:30

  4. thank j

    Anonymous

    Mon, 2012-05-21 at 23:29:15 +05:30


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 70 other followers