在Mac下可以使用.ssh/config
实现快速免密钥登录主机。这里使用的是密钥,这里可以使用密码登录吗?如何指定?
Host phicomm
Hostname xxx
Port xxx
User root
ServerAliveInterval 30
ControlMaster auto
ControlPath /tmp/master-%r@%h:%p
ControlPersist yes
IdentityFile ~/.ssh/id_rsa
看man手册的说明,不支持写入密码。不过你可以用
sshpass
传递密码给ssh命令,比expect
脚本好用太多了