gpt4 book ai didi

linux - 通过shell脚本传递scp的密码

转载 作者:太空宇宙 更新时间:2023-11-04 05:43:06 25 4
gpt4 key购买 nike

我有一个 shell 脚本,其中包含以下命令将 test.dat 文件从远程服务器复制到我的当前目录:

scp remote_user_id@remote_server_name:<filepath>/test.dat .

执行脚本时,它要求输入密码,我必须手动输入该密码。我无权安装或使用 sshpass 或期望甚至设置 ssh。如何在 shell 脚本中传递此密码?

最佳答案

使用公钥认证

 -i identity_file

Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to ssh(1).

您还可以使用 rsync。 rsync 有类似 --password-file 的选项

关于linux - 通过shell脚本传递scp的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40359390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com