如果你还在使用 iTerm
, alias
管理 服务器, 可以试试下面 sshmenu
安装 sshmenu
# git clone https://github.com/selboo/sshmenu.git
# cd sshmenu
# python setup.py install
/root/sshmenu.json
# cat /root/sshmenu.json
{
"targets": [
{
"host": "selboo@192.168.1.100",
"command": "/bin/ssh",
"friendly": "pi",
"options": [
"-p60777",
"-i/root/.ssh/selboo_id_rsa",
"-F/root/env/ssh/config",
"-oStrictHostKeyChecking=no",
"-oConnectTimeout=3"
]
},
{
"host": "aikaiyuan@www.aikaiyuan.com",
"command": "/bin/ssh.sh",
"friendly": "vps usa",
"options": [
"password123",
"-oStrictHostKeyChecking=no",
"-oConnectTimeout=3"
]
},
{
"host": "root@192.168.199.100",
"command": "/bin/ssh.sh",
"friendly": "pi 4B",
"options": [
"mima321",
"-oStrictHostKeyChecking=no",
"-oConnectTimeout=3"
]
},
{
"host": "root@1.1.1.200",
"command": "/bin/ssh.sh",
"friendly": "test server",
"options": [
"1234567890",
"-p65500",
"-oTCPKeepAlive=yes",
"-oStrictHostKeyChecking=no",
"-oServerAliveInterval=30",
"-oConnectTimeout=3"
]
}
]
}
- host: [user]@[host|ip]
- command: /bin/ssh or /bin/ssh.sh
- friendly: 备注
- options:
- 第一行是密码
- -p: 端口
- -oTCPKeepAlive=yes : 保持回话
- -oStrictHostKeyChecking=no 不检查known_hosts
- -oServerAliveInterval=30 : 保持回话
- -oConnectTimeout=3: 连接超时
- 更多配置可以
man ssh
/bin/ssh.sh
#!/usr/bin/expect
set timeout 20
set cmd [lrange $argv 1 end]
set password [lindex $argv 0]
eval spawn "ssh $cmd"
sleep 1
expect "(yes/no)?" {
send "yes\r"
expect "*assword:"
send "$password\r";
} "*assword:" {
send "$password\r";
} "*assword: " {
send "$password\r";
} "*assword:" {
send "$password\r";
} "# " {
send "";
} "$ " {
send "";
}
interact
/root/env/ssh/config
Host *
ControlMaster auto
ControlPath /tmp/%r@%h
ControlPersist 86400
启动
# alias myssh="sshmenu -c /root/sshmenu.json"
# myssh
Select a target (press "h" for help)
ID User | Host | Note | Login
-> 1 selboo | 192.168.1.100 | pi | No
2 aikaiyuan | www.aikaiyuan.com | vps usa | No
3 root | 192.168.199.100 | pi 4B | No
4 root | 1.1.1.200 | test server | No