新建**.sh文件,写入以下内容:
#!/usr/bin/expect
set timeout 3
spawn ssh username@ip
expect "*password*"
send "password\r"
interact
之后添加可执行权限
chmod +x **.sh
之后./**.sh运行该脚本即可 PS:本脚本仅适合连接已连接过的ssh服务器 报错:-bash: ./nanorobot.sh: /usr/bin/expect: bad interpreter: No such file or directory 解决方案:shell sudo apt install expect