if [ $# -eq 0 ] //Check whether u have given any argument
then
echo "Input the lan ip for ssh"
elif [ $# -eq 1 ] //check if argument is equal to one [means default is root connecting]
then
echo "Connecting to 172.22.$1 as root"
ssh root@172.22.$1 -X
else "Connecting to 172.22.$1 as $2" //take the second argument which is the username.
ssh $2@172.22.$1 -X
fi
1)Name the file as c then [c for connect]
2)Store this file under /usr/bin may be with a name C. [so that u can access this like command]
3)Run the command
4)chmod 711
So now i have to type to connect ssh
c yy.zz [to connect ssh root@172.xx.yy.zz]
c yy.zz username [to connect ssh username@172.22.xx.yy.zz]
This code if provided with 2nd argument which is considered as username then it will connect to that username else it will connect to root.
So in this way i make my work easier.
No comments:
Post a Comment