美文网首页
linux免密传输文件

linux免密传输文件

作者: 偏执的感叹号 | 来源:发表于2020-11-26 15:53 被阅读0次

    主要是基于expect+scp进行操作

    核心操作脚本如下:

    expect -c "
            spawn scp -P 端口 指定文件  <用户名>@<目标机器ip>:<目标文件夹地址>
            expect {
                \"*assword\" {set timeout 300; send \"密码\r\"}  # 超时时间
            }
            expect 100%
            expect eof"
    

    注: 若出现文件传送不完全,多是由于传送时间超过设定时间。expect默认超时时间是30s,本次脚本超时时间为5分钟.

    相关文章

      网友评论

          本文标题:linux免密传输文件

          本文链接:https://www.haomeiwen.com/subject/rbxziktx.html