1#!/usr/bin/expect // 指定shebang 2 3set timeout 3 // 设定超时时间为3秒 4spawn ssh user_name@172.***.***.*** // fork一个子进程执行ssh命令 5expect "*password*" // 期待匹配到 'user_name@ip_string's password:' 6send "my_password\r" // 向命令行输入密码并回车 7send "sudo -s\r" 8send "cd /data/logs\r" // 帮我切换到常用的工作目录 9interact // 允许用户与命令行交互
Shell实现自动登录ssh
Stella981
2021-10-12
1380 0 0
点赞
收藏
评论区
加载中...