Script to create ssh passwordless between two Linux Server

Posted: October 27, 2017 in create ssh passwordless b/w two Linux server, Shell Script

echo “Script to create password less between Linux Server”
echo “Enter Remote_username :”
read user

if [ $user != ‘root’ ]
echo “ssh passwordless connection only for full privilege user”
exit 1

echo “Enter Remote_Server_IP :”
read ip

/usr/bin/ssh -o PasswordAuthentication=no $user@$ip /bin/true
if [ $? -eq 0 ]; then
echo Already passwordless connection between two systems
exit 1
echo ssh passwordless connection is not yet enabled between two system

if [ -e /root/.ssh/ ]
echo “Already ssh key generated”
echo ” Generating ssh key ”
ssh-keygen -t rsa

ssh-copy-id $user@$ip
sleep 2

echo “Testing SSH password less connection”
ssh -q $user@$ip echo “test”
if [ $? -eq 0 ]; then
echo Passwordless enabled successfully and connection also tested
exit 1
else echo test connection have issue

  1. This is adorable! I really like your happy birthday card. Have a marvelous day.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.