ZKX's LAB

自动scp脚本 一行命令 如何在脚本中执行scp时自动输入密码

2021-04-07知识2

如何在脚本中执行scp时自动输入密码? 脚本如下:usr/bin/expect-fset password spawn scp 用户名@目标机器ip:拷贝文件的路636f70793231313335323631343130323136353331333365636133径 存放本地文件的路径set timeout 300expect\"用户名@目标机器ip's password:\"#注意:这里的“用户名@目标机器ip”跟上面的一致set timeout 300send\"$password\\rset timeout 300send\"exit\\rexpect eof附:scp参数r:拷贝目录c:允许压缩一个完整的例子usr/bin/expect-fset password 123456downloadspawn scp root@192.168.1.218:/root/a.wmv/home/yangyz/set timeout 300expect\"root@192.168.1.218's password:set timeout 300send\"$password\\rset timeout 300send\"exit\\rexpect eofuploadspawn scp/home/yangyz/abc.sql root@192.168.1.218:/root/test.sqlset timeout 300expect\"root@192.168.1.218's password:set timeout 300send\"$password\\rset timeout 300send\"exit\\rexpect eof

如何在脚本中执行scp时自动输入密码 1.下载安装sshpass工具。2.安装:configuremakemake install3.为了能在任意地方执行命令 cp sshpass/user/bin/4.执行的命令如下:sshpass-p$PASSWD scp-o StrictHostKeyChecking=no$CMD`cd$path&sshpass-p HS~u8ro8e scp-o StrictHostKeyChecking=no$package javadev\\@121.199.60.78:/home/javadev/server`;

如何用expect写一个自动登录脚本 1.安装expect 1.安装expect 需要先安装tcl:apt-get install tcl apt-get install expect 2.expect使用 2.1一个简单的输入密码操作#!usr/bin/expect set timeout 100 set 。

#自动scp脚本 一行命令

qrcode
访问手机版