Archive for the ‘create ssh passwordless b/w two Linux server’ Category


#!/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