在linux上使用scp命令传输文件时,每传输一次,都要填写目标服务器的登录密码,十分麻烦。
配置系统密钥又比较复杂,于是想到的使用expect写一个自动填充密码的脚本,脚本内容如下:
scp.sh

#!/usr/bin/expect
set timeout 30
set file [lindex $argv 0]

spawn scp $file root@xxx.xxx.xxx.xxx:目标服务器文件保存路径

expect -re "password:" { send "你的服务器密码\r" }
expect eof

使用:
./scp.sh [文件路径]

相关文章:

  • 2022-01-04
  • 1970-01-01
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-07
  • 2023-03-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
相关资源
相似解决方案