Wednesday, October 9, 2013

How to connect to any machine without password using SSH ? And how to configure ? 9/10

Hi All,

Here I am going to show you how to connect to any machine with the use of ssh.

Here we consider two machines  ( both are Linux here)
1) Master
2) Slave

Now the scenario is, I want to access Master machine from Slave Machine.

What to do:
Steps...

- Install openssh-server in both of these machines.
                       Use command 'sudo apt-get install openssh-server'
- ssh configuration files are created in the location ' ~/.ssh ' is a directory.
- Since Slave wants to connect to Master, Slave needs public key of Master machine in it.

Note: Think the machine name nagarjuna@nagarjuna-Aspire-4736 is a Master Machine.

pic1:


- Generate public key, using ssh-keygen command in Master machine

pic2:

- we get files like below, can see using tree command.

pic3:

- Here we need the file named ' id_rsa.pub ' to be copied to Slave machine.


Key Copying process to Slave Machine:

- Create a touch file with the name ' authorized_keys ' under the .ssh folder in the Slave machine.
- And now copy the Masters ' id_rsa.pub ' content to ' authorized_keys ' file using below command
  ' cat id_rsa.pub >>authorized_keys ' .
- Now connect to Master using the command ' ssh nagarjuna@nagarjuna-Aspire-4736 ' in the Slave Machine.


Troubleshooting :

- If you are unable to connect to master machine. Follow below steps
1) The above process will be successed only when domain is registered with an IP address.
2) Otherwise edit the public key - meaning - at the end of the public key, we will see domainname like
nagarjuna@nagarjuna-Aspire-4736.  Here you have to replace nagarjuna-Aspire-4736 with the IP address of Master machine.
3) Now try to connect.

If you want to know the IP address of Master machine, use the command ' ifconfig ' , You will IP.


If you still facing problems while connecting, then try to restart ssh server service in both Machines using
sudo /etc/init.d/ssh restart


sources:
https://help.ubuntu.com/10.04/serverguide/openssh-server.html
http://www.cyberciti.biz/faq/howto-start-stop-ssh-server/




No comments:

Post a Comment