System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

not able to do passwordless ssh as normal user

 
SOLVED
Go to solution
laiju.c.babu
Regular Advisor

not able to do passwordless ssh as normal user

Hi  Team,

 

Aim:-

=====

User want  to set up a passwordless ssh for a user user1  from the sever A to the server B

 

Actions Performed :-

================

1) Logged  to the server A as root

2) su  to the normal user (user1)

3) created the ssh-keygen

4) copied the key from server A  to server B

5) Now as that normal user i am able to do passwordless ssh  to hpux79a4

Now the customer requirement:

==========================

The user will log in to the server as another  normal user (user2) then execute the below command

Server A : user2 $ >  ssh  user1@server B  date

 

Here its asking for password ...

 

Could  you please help me on this

 

Regards

 

Laiju.C.Babu
5 REPLIES
madhuthelearner
Occasional Advisor

Re: not able to do passwordless ssh as normal user

HI,

 

In server B,copy the key to authorized_keys file.

 

just like,

 

 

cat id_rsa.pub > authorized_keys.

 

regards

 

Madhu

madhuthelearner
Occasional Advisor

Re: not able to do passwordless ssh as normal user

Hi,

 

if there are more eys

 

append as

 

 

cat id.rsa.pub >> authorized_keys

 

 

regards

 

Madhu

laiju.c.babu
Regular Advisor

Re: not able to do passwordless ssh as normal user

Hi Madhu,

Thanks for the reply.

 

I had copied the key to that file.

 

And i am able to do passwordless ssh as user1. I am facing the  issue when i am following the below process

 

1) Logging to the server A as user2

 

2)  ssh user1@Server B date   ========> Here its asking for password

 

If i am logging ot server A as user1 and doing the below command its working

 

ssh server B date ========> this is working fine

 

Regards

Laiju.C.Babu
Matti_Kurkela
Honored Contributor
Solution

Re: not able to do passwordless ssh as normal user

In general, if you want to allow user X at server A to login as user Y to server B, the requirements are:

  • there must be a SSH private key in ~userX/.ssh/id_rsa on server A
  • the matching public key must be added to ~userY/.ssh/authorized_keys on server B.

In your case, your user1 now has an appropriate set-up for passwordless SSH for logging in as user1@serverB.

 

To allow user2@serverA to login as user1@serverB too, the best practice is to generate another SSH key pair as user2@serverA, and then add user2's public key to ~user1/.ssh/authorized_keys on serverB.

# cat user2key.pub >> ~user1/.ssh/authorized_keys

 

The authorized_keys file can hold an unlimited number of public keys (although if you have a massive number of public keys, login may be slow).

 

The reason for creating a separate key for each user is: if one of the users misplaces his/her private key (so that an unauthorized person may use it), you can easily remove the matching public key from the authorized_keys file and replace it with a new public key, without causing any inconvenience to the other users.

MK
laiju.c.babu
Regular Advisor

,Re: not able to do passwordless ssh as normal user

Hi MK,

 

Thanks for the reply, the issue is resolved

 

Resolved

Laiju.C.Babu