Thursday, 17 January 2013

Remote Login,Copying file and Passwordless login using SSH


What is SSH (Secure Shell) ?


SSH is developed by Communications Security Ltd. It is also known as Secure Socket Shell ,it is a protocol for securely getting access to a remote computer and move files from one machine to another. The connections are secured through digital certificate.


Installing SSH


OpenSSH is a open source version of the SSH connectivity tool in Ubuntu. To install 

sudo apt-get install openssh-client openssh-server

To login into the remote server enter the following command

ssh username@user_ip 

When entered you will be asked whether to continue. Choose Yes. Then you are asked to give the remote machine's password.Now you can control the remote machine through the terminal.


Copying files using SSH

 

Open SSH is used for transferring files to remote system through a secure connection. Command used is

scp file.txt username@user_ip:directory

eg: scp file.txt abc@10.20.34.124:/home/abc/doc

To copy a file from the server to the local machine, use the following syntax:

  scp server@10.20.34.124 :home/server/file.txt  /home/abc/

 Here 'server' is the username of remote machine and ip of the server .'file.txt' from server is copied to local machine of 'abc'. 


Passwordless Authentication 


Open SSH can be used to setup passwordless authentication. Instead of entering the remote server's password on each login attempt, SSH will create a public/private key pair and send the public key to the remote server.The private key is stored on the local machine. This completely eliminates the need to send sensitive information (like a password) over the network.

 Following commands are used:

1. To generate key pair

[jothis@jothis.com ~]$ ssh-keygen  
 
Then you will be asked to provide the file name and a password.Enter the password and the filename. It will generate a private and public key for the communication.
 

2.Copy the public key stored to the server

ssh-copy-id -i ~/.ssh/filename.pub remoteuser_name@remote _ip

'./ssh/filename.pub' is the location of the public key in the localhost. Then you will be asked to provide the password of the remote server.Now the public key of the local machine is stored into the remote server.

3.Remote logging without password

ssh username@user_ip  

just like login into remote server from local host.





 


 

No comments:

Post a Comment