SSH 密码登录
#!/usr/bin/expect -f set password "123456" set timeout -1 spawn ssh user@xxx.xxx.xxx.xx expect "*assword:*" send "$password\r" expect "Last*" interact
SSH 证书登录
#!/usr/bin/expect -f set password "123456" set timeout -1 spawn ssh -i /Users/user/Cert/id_rsa user@xxx.xxx.xxx.xx -p 30022 expect "*passphrase*" send "$password\r" expect "Last*" interact
添加命令别名:
~/.bash_profile文件:
alias server1='/Users/ice/server1'
source ~/.bash_profile 可以立即生效
输入server1 可以直接进入服务器。
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
真诚赞赏,手留余香
赞赏