使用 SCP 命令传输文件因相对路径失败而适用于绝对路径

Transferring file using SCP command fails with relative path and works with absolute path

这是失败的。 (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:~/

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

$ sudo chmod 744 file.txt

然后尝试 scp