Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ~/.aliases
- function ssh2 {
- host=$1
- user=$2
- pass=$3
- if [ -z "$host" -o -z "$user" -o -z "$pass" ];then
- echo $0 host user pass
- else
- expect="~/bin/ssh.ex $host $user $pass"
- n=$(( ( RANDOM % 4) + 2457 ))
- HOST=`echo $HOST | tr '[:upper:]' '[:lower:]'`
- if [[ $HOST =~ jumphost ]];then
- $expect
- else
- ssh -A -t jumphost$n $expect
- fi
- fi
- }
- # ~/bin/ssh.ex
- #!/usr/bin/expect -f
- # ./ssh.exp password 192.168.1.11 id
- set pass [lrange $argv 0 0]
- set server [lrange $argv 1 1]
- set name [lrange $argv 2 2]
- spawn ssh $name@$server
- match_max 100000
- expect "*?assword:*"
- send -- "$pass\r"
- send -- "\r"
- interact
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement