【问题标题】:Passing Password for scp through shell script通过 shell 脚本为 scp 传递密码
【发布时间】:2017-03-14 13:14:57
【问题描述】:

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

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

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

【问题讨论】:

标签: linux shell unix scp


【解决方案1】:

使用公钥认证

 -i identity_file

选择从中读取用于公钥认证的身份(私钥)的文件。此选项直接传递给 ssh(1)。

您也可以使用 rsync。 rsync 有 --password-file 之类的选项

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    • 1970-01-01
    • 2011-10-10
    • 2022-01-12
    • 2023-03-11
    相关资源
    最近更新 更多