Script to create ssh passwordless between two Linux Server

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

#!/bin/bash
echo “Script to create password less between Linux Server”
echo “Enter Remote_username :”
read user

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

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
else
echo ssh passwordless connection is not yet enabled between two system
fi

if [ -e /root/.ssh/id_rsa.pub ]
then
echo “Already ssh key generated”
else
echo ” Generating ssh key ”
ssh-keygen -t rsa
fi

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
fi

Comments
  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:

WordPress.com Logo

You are commenting using your WordPress.com 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.