安装tcl tclx tcl-devel
yum install -y tcl tclx tcl-devel
安装expect
yum install expect -y
创建文件ssh_quick.epr
#!/usr/bin/expect
if {$argc < 1} {
set remote_host "10.24.18.3"
} else {
set remote_host [ lindex $argv 0 ]
}
puts $remote_host
spawn ssh root@$remote_host
expect "*assword:"
send "123456\r"
expect "*#"
interact
然后就可以使用:
expect ~/ssh_quick.epr
完成快捷登录ssh的操作了。
ln -s shd="expect ~/ssh_quick.epr"
创建快捷方式进一步简化指令