【问题标题】:Transferring file using SCP command fails with relative path and works with absolute path [closed]使用 SCP 命令传输文件失败并使用相对路径并使用绝对路径 [关闭]
【发布时间】:2023-12-05 20:34:01
【问题描述】:

这是失败的。 (file.txt 在同一个文件夹中)

sudo scp file.txt shahid@11.34.45.23:~/
#gives error Permission denied (publickey).

以下工作,但是,它要求本地机器密码

sudo scp me@localhost:/home/file.xt shahid@11.34.45.23:~/

【问题讨论】:

  • 对于 本地 机器?这意味着 sudo 正在询问密码,并且它与scp 无关,后者会询问遥控器的密码。

标签: linux bash ssh file-transfer scp


【解决方案1】:

如果file.txt 不包含任何关键数据,请更改其权限以允许其他人阅读:

$ sudo chmod 744 file.txt

然后试试scp

【讨论】: