Shuttle是 https://github.com/fitztrev/shuttle 的免费开源软件。javascript
使用expect脚本能够根据屏幕显示的要求自动输入相应的指令。java
编写/data/ssh/ssh-server.shgit
#!/usr/bin/expect set timeout 30 spawn ssh -p [lindex $argv 0] [lindex $argv 1] expect { "(yes/no)?" {send "yes\n";exp_continue} "Password:" {send "[lindex $argv 2]\n"} " password:" {send "[lindex $argv 2]\n"} } interact
其中[lindex $argv 0] 表示提供的第一个参数,其余的以此类推github
Shuttle配置:bash
{ "_comments": [ "Valid terminals include: 'Terminal.app' or 'iTerm'", "In the editor value change 'default' to 'nano', 'vi', or another terminal based editor.", "Hosts will also be read from your ~/.ssh/config or /etc/ssh_config file, if available", "For more information on how to configure, please see http://fitztrev.github.io/shuttle/" ], "editor": "default", "launch_at_login": false, "terminal": "Terminal.app", "iTerm_version": "nightly", "default_theme": "Homebrew", "open_in": "new", "show_ssh_config_hosts": false, "ssh_config_ignore_hosts": [], "ssh_config_ignore_keywords": [], "hosts": [ { "cmd": "ssh-server.sh 22 root@192.168.5.10 pwd4root", "name": "测试SSH服务器" }] }
保存后,使用Shuttle直接在菜单中选中“测试SSH服务器” 便可实现免输入密码登陆.服务器