scp自动写密码脚本

发布时间:2020-07-11 00:33:03 作者:zhaogaolong8
来源:网络 阅读:337

scp自动写密码脚本

#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set src_file [lindex $argv 3]
set dest_file [lindex $argv 4]
spawn scp $src_file $username@$host:$dest_file
 expect {
 "(yes/no)?"
  {
  send "yes\n"
  expect "*assword:" { send "$password\n"}
 }
 "*assword:"
{
 send "$password\n"
}
}
expect "100%"
expect eof

使用格式:

./scp.sh  [目标IP地址] [用户名] [密码] [文件名]  [目标位置]

./scp.sh  172.168.24.1 root awcloud demo.tar.gz  /root/

推荐阅读:
  1. expect使用脚本实现自动输入密码
  2. shell中scp自动输入密码

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

密码 scp

上一篇:chattr与lsattr管理系统关键文件

下一篇:Nginx虚拟主机配置实践(一)

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》