How to SSH without Password into remote Linux Server is the question that every Engineer working on Linux might have come across.
Sometimes the Question we seek could be different like
- ssh command without password
- ssh to the remote server without password
- SSH without password from Shell Script
- SCP to a remote server without password From Shell Script
- Passwordless SSH and SCP between Linux servers. etc..
But the solution remains the same. Which is enabling Key Based Authentication between servers
So, How to enable SSH Key based authentication (or) Passwordless SSH in 2 steps
Execute the following commands in the server from where you are going to log in to the other (or) initiate the SSH command.
For example, If you want to log in to
mwiapp02 server from
wlsusr user. You should perform the following steps in
Step1: Create SSH key for your username (if not already created) using the following command
This Step is to create SSH Key for your user. The Generated SSH Key file would be placed in Home Directory of the current user under
The Filename of this Key would be
ssh-keygen -q -b 2048 -t rsa -N "" -C "creating SSH" -f ~/.ssh/id_rsa
Step2: Copy the key file to the remote server to which you would like to login
ssh-copy-id command you can actually copy the public key of your user ( Generated from the last command) to the remote server and it would be appended into the
You can optionally do the aforementioned step manually also. But
ssh-copy-id is the easy and efficient way to do it
Here is a quick Demo on how to do it.
SSH from Shell Script and Execute commands after Key Based Authentication Enabled
As we are now having Passwordless SSH enabled you can do SSH and SCP without being prompted for the password.
Here is a Sample Script which copy an another Script file which has to be executed on the remote Server using SCP and invokes it with SSH.
Hope it helps
Rate this article [ratings]