1、创建login.sh脚本
touch login.sh
#!/usr/bin/expect
spawn ssh xxx@xxxxx
expect "*password:"
send "password\r"
interact
2、设置别名
vim .bash_profile
添加以下设置:
alias 自定义名称='已有指令名称'
例如:
alias ll='ls -al'
source .bash_profile
3、执行操作
执行login,顺利登录
4、shell字段讲解:
spawn:启动新的进程
expect:从进程接收字符串
send:用于向进程发送字符串
interact:允许用户交互