自动登录服务器shell
文件: ssh.sh
#!/bin/bash
ip=84;
if [ $1 ];then ip=$1; fi
# Kata-Aliyun
# Kata-虚拟机
if [ $ip -eq 136 ]; then ssh='root@192.168.20.136' pwd='123456'; fi;
if [ $ip -eq 137 ]; then ssh='root@192.168.20.137' pwd='123456'; fi;
if [ $ip -eq 138 ]; then ssh='root@192.168.20.138' pwd='123456'; fi;
##### #####
expect -c "
spawn ssh $ssh
expect {
\"yes\/no\" { send \"yes\n\"; exp_continue}
\"password:\" { send \"$pwd\n\" }
}
interact
"
# 软连 ln -s /Applications/work/sh/ssh.sh(文件路径) /usr/bin/sshs
# 登录 sshs 136