Support Questions
Find answers, ask questions, and share your expertise

ambari-server Regarding SSH

ambari-server Regarding SSH

Explorer

I was created SSH and stored in the /.ssh/id_rsa location and also copied the id_rsa.pub to child node. used chmod 700 for .ssh and chmod 600 for /.ssa/id_rsa.pub.

Now I am trying to connect childnode without password but still it is asking password for connect the child node.

I would like to connect the child node without password but no luck. Are any IP settings needed ?

Please let me know.

Thanks,

Narender.

5 REPLIES 5

Re: ambari-server Regarding SSH

From "node1" host where you created the "id_rsa.pub" file you will need to push it to other hosts where you want to do passwordless ssh.

[root@node1 ~]# ssh-copy-id   -i ~/.ssh/id_rsa.pub     root@node2.host.com

[root@node1 ~]# ssh-copy-id   -i ~/.ssh/id_rsa.pub     root@node3.host.com

[root@node1 ~]# ssh-copy-id   -i ~/.ssh/id_rsa.pub     root@node4.host.com

Re: ambari-server Regarding SSH

Else as another alternative you will need to copy the contents of file "~/.ssh/id_rsa.pub" and paste it to the other hosts in the following file "~/.ssh/authorized_keys" (If this file does not exist there already then you will need to create one and then paste the contents of "id_rsa.pub" from node1 to this file "~/.ssh/authorized_keys" of all hosts:

Re: ambari-server Regarding SSH

Super Collaborator

Hi @narender pasunooti:

i am explaining the concept with 2 servers(server1,server2)

in server1 you need generate ssh keys and private key must stored in /home/user/.ssh with 400 permission

in server2 you need to copy authorizedkeys(copy of id_rsa.pub) in /home/user/.ssh/)wiht 600 permsssion.

Now you can able to do ssh server2 from server1 without enter the password

for reference: http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

Re: ambari-server Regarding SSH

I think @Joy's using ssh-copy-id would be the easiest.

If server doesn't have ssh-copy-id, you can do below:

ssh root@node2.host.com "echo `cat ~/.ssh/id_rsa.pub` >> /root/.ssh/authorized_keys"

ssh root@node3.host.com "echo `cat ~/.ssh/id_rsa.pub` >> /root/.ssh/authorized_keys"

ssh root@node4.host.com "echo `cat ~/.ssh/id_rsa.pub` >> /root/.ssh/authorized_keys"

Re: ambari-server Regarding SSH

Expert Contributor

Follow below steps it worked for me.

1) Generate the ssh-key from "root" user

$sudo su - root

$ssh-keygen

it will create "id_rsa.pub" and "id_rsa".

2) Before copying, please check are you able to ping the host

#ping target_hostname, if you able to ping the target directory

copy "id_rsa.pub" traget host, before that create the directory with root user only

target host#mkdir /.ssh/authorized_keys and source host as well

Once create copy that generated the SSH-KEYGEN ed_rsa.pub file to authorised_keys.

#cd .ssh

#cat id_rsa.pub >> authorized_keys

#scp authorized_keys root@targethost:/root/.ssh

try to connect from source to target host without password, if its fine, then copy same source to which server you want connect without password.

Your comments are appreciated