How to automate ssh

Please find below the script and run form client machine from where you want to set login without password.

#!/bin/bash
#withoutPasswordLogin.sh
#Author       : Mahendra Pratap Singh
#Created on   : Dec 18, 2013
#Modified on  : Dec 18, 2013
#Version      : 1.1

#Description  : This script is to automate login on linux machine without password, Script says one time password only.

# Usage: sh withoutPasswordLogin.sh

secureKeyGeneration()
{
	
if [[ ! -f $HOME/.ssh/id_dsa ]] &&  [[ ! -f $HOME/.ssh/id_dsa.pub ]]
then
	mkdir –p $HOME/.ssh
	chmod 0700 $HOME/.ssh
	ssh-keygen -t dsa -f .ssh/id_dsa -P ''
else
	echo " Secure Key Already Generated"
fi
}

#creating temp script

secureKeyScript()
{
	touch $HOME/.ssh/id_dsaSecureKey.sh
	echo '#!/bin/bash' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'echo ""' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'mkdir –p $HOME/.ssh' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'chmod 0700 $HOME/.ssh' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'touch $HOME/.ssh/authorized_keys2' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'touch $HOME/.ssh/authorized_keys' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'cat $HOME/id_dsa.pub >> $HOME/.ssh/authorized_keys2' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'chmod 0600 $HOME/.ssh/authorized_keys2' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'ln –s $HOME/.ssh/authorized_keys2 $HOME/.ssh/authorized_keys' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'cd $HOME' >> $HOME/.ssh/id_dsaSecureKey.sh
	echo 'rm -f id_dsa*' >> $HOME/.ssh/id_dsaSecureKey.sh
	chmod 777 $HOME/.ssh/id_dsaSecureKey.sh
}
	
scriptAgrgument()
{
	echo "Please enter remote machine IP Address"
	read ipInput
	echo ""
	echo "Please enter remote machine Username"
	read usernameInput
	scp $HOME/.ssh/id_dsa* $usernameInput@$ipInput:/$HOME
	echo ""
	echo "Please re-enter remote machine Password"
	echo ""
	ssh $usernameInput@$ipInput $HOME/id_dsaSecureKey.sh
	echo "cleaning up"
	rm -f $HOME/.ssh/id_dsaSecureKey.sh
}

main()
{
	secureKeyGeneration
	secureKeyScript
	scriptAgrgument
}

main

Different remedies existing from the Web to why to waste time and visit dispensary if you can easily purchase medications sit at home. There are numerous of legal online drugstores that will deliver remedies to your home. If you are considering Cialis, you probably want to study more about Cialis. (See also Amoxicillin Over the Counter). This website provides you with some useful info on the benefits of remedies and how they are evaluated for safeness. Generally, both men and women are afflicted by sexual disorders. Often, when people think about Cialis, they mean Generic Amoxil Amoxicillin. The very momentous question you must look for is Cialis. (Read more Other Forms of Metronidazole). Finally, such kind of difficulties can be an early warning symptom of serious soundness problems, such as heart disease. Finally ordering remedies online can save money, but keep these tips in mind.


Posted

in

by

Comments

Leave a Reply