0514-86177077
9:00-17:00(工作日)
首先創建一個expect腳本ssh_expect,文件內容如下:
#!/usr/bin/expect -f set hostname [lindex $argv 0] set user [lindex $argv 1] set passwd [lindex $argv 2] set timeout 30 set force_conservative 1 if {$force_conservative} { set send_slow {128 .1} } spawn ssh $user@$hostname; expect { "*continue connecting (yes/no)?" { send -s "yes\r"; exp_continue } "*assword:" { send -s "$passwd\r"; } } interact
然后定義一些命令別名,比如:
alias h101='ssh_expect 192.168.0.101 user> password>' alias h102='ssh_expect 192.168.0.102 user> password>'
這些別名可以寫到~/.bashrc文件中
然后執行 h101 就可以自動登錄192.168.0.101機器了。
標簽:鎮江 丹東 優質小號 自貢 滁州 六盤水 百色 武漢
上一篇:linux下ssh安裝與scp命令使用詳解
下一篇:Linux系統中掩耳盜鈴的sudo配置
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8