Script: SSH auto multi login.

Posted on

I have using to login my server through my gateway server.

#Script to login to gateway server and initiate login to internal server
#!/bin/bash
_Terminal="/usr/bin/gnome-terminal --maximize"
QT="42"

Exec(){
echo -e "#!/usr/bin/expect -f
spawn ssh -l root Mydomain.gateserver.com
send -- "$QT"ssh root@$1\r"$QT"
interact" > /tmp/$_ServerName
chmod +x /tmp/$_ServerName
}

while read char
do
_ServerName=`echo $char |awk '{print $2}'`
_ServerIP=`echo $char |awk '{print $3}'`
Exec $_ServerIP
_Tabs=""$_Tabs" --tab-with-profile="Default" --title=$_ServerName -x "/tmp/$_ServerName""
done < $1

eval $_Terminal $_Tabs
exit

#Input file syntax

My.server1.domain.com 111.222.333.444
My.server2.domain.com 122.332.353.411
My.server3.domain.com 131.282.393.42

#usage

./Script intpufile
Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s