我希望在HP-UX中创建一个脚本来发送带有密码的sftp。我有个命令
sftp -o PasswordAuthentication=
但是,如果我回答是或否之后,我有这个问题“主机密钥验证失败”
发布于 2013-10-03 14:38:44
如果您手头有socat
,您可以使用手册中的这个示例。
(sleep 5; echo PASSWORD; sleep 5; echo ls; sleep 1) |
socat - EXEC:'ssh -l user server',pty,setsid,ctty
EXEC’utes an ssh session to server. Uses a pty for communication
between socat and ssh, makes it ssh’s controlling tty
(ctty), and makes this pty the owner of a new process group
(setsid), so ssh accepts the password from socat.
发布于 2015-01-27 14:06:54
最好使用公钥/私钥身份验证,但如果您仍然希望在纯文本脚本中使用密码,我将使用lftp
。它是一个很好的客户机,它允许ftp、sftp、ftps连接,您只需要使用“这里文档”来完成事务:
lftp sftp://your.destination.sftp -u yourUser,YourPassword << fin
get yourfile
bye
fin
发布于 2015-09-23 09:57:17
您可以在sftp脚本下面使用用户名、密码和说明。
#!/usr/bin/expect
spawn sftp username@destip
expect "username@destip's password:"
send "passwd\n"
expect "sftp>"
send "get filename\n"
expect "sftp>"
send "bye\n"
https://unix.stackexchange.com/questions/93424
复制相似问题