如何使用Bash脚本中的密码运行sftp命令?我需要使用sftp来自Linux主机。我从我的行动组获得了同样的证书。但是,由于我无法控制其他主机,所以无法生成RSA密钥并与另一个主机共享。那么有什么方法可以运行sftp命令(提供用户名/密码)从Bash脚本内部通过克隆工作?我发现了一个类似的堆栈溢出问题,在Bash脚本中指定sftp密码但对我的问题没有令人满意的答案。
3 回答

九州编程
TA贡献1785条经验 获得超4个赞
使用 键链
使用 刀柄
(安全性较低,但可能符合您的要求) 使用 期待
(安全性最低,需要更多编码)
export SSHPASS=your-password-here sshpass -e sftp -oBatchMode=no -b - sftp-user@remote-host << ! cd incoming put your-log-file.log bye!

缥缈止盈
TA贡献2041条经验 获得超4个赞
sudo apt-get install expect
yum install expect
#!/usr/bin/expectspawn sftp username@hostname.com expect "password:"send "yourpasswordhere\n"expect "sftp>"send "cd logdirectory\n"expect "sftp>"send "put /var/log/file.log\n"expect "sftp>"send "exit\n"interact
添加回答
举报
0/150
提交
取消