尽管 SSH 运行正常,但尝试 SCP 文件时权限被拒绝

尽管 SSH 运行正常,但尝试 SCP 文件时权限被拒绝

我已经成功通过 SSH 连接到远程服务器,并且正在尝试使用 SCP 命令在本地计算机和远程服务器之间传输一些文件。

当我登录远程服务器并尝试将文件从远程服务器传输到我的计算机时,出现权限被拒绝错误:

alexa@server:~/project$ scp alexa@server:~/project/requirements.txt /mnt/c/Users/Alexa/Desktop/
alexa@server: Permission denied (publickey).

当我尝试执行反向操作并在登录本地计算机后将文件从本地计算机传输到远程服务器时,我得到了以下信息:

alexa@local:/mnt/c/Users/Alexa/Desktop/$ scp test_doc.txt alexa@server:~/project/
ssh: Could not resolve hostname server: Name or service not known
lost connection

我检查了所有文件和文件夹的权限,发现 alexa 是所有者。此外,我尝试使用 sudo 执行相同的命令,但结果是一样的。

调试显示了这一点

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/alexa/.ssh/id_rsa
debug3: no such identity: /home/alexa/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/alexa/.ssh/id_dsa
debug3: no such identity: /home/alexa/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/alexa/.ssh/id_ecdsa
debug3: no such identity: /home/alexa/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/alexa/.ssh/id_ecdsa_sk
debug3: no such identity: /home/alexa/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /home/alexa/.ssh/id_ed25519
debug3: no such identity: /home/alexa/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/alexa/.ssh/id_ed25519_sk
debug3: no such identity: /home/alexa/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/alexa/.ssh/id_xmss
debug3: no such identity: /home/alexa/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
alexa@server: Permission denied (publickey).

当我检查 /home/alexa/.ssh/ 的内容时,我只看到 2 个文件:

alexa@server:~/.ssh$ ls -la
total 16
drwx------ 2 alexa alexa 4096 Jun 26 13:12 .
drwxr-xr-x 8 alexa alexa 4096 Apr 13 18:11 ..
-rw------- 1 alexa alexa  736 Apr  1 15:53 authorized_keys
-rw-r--r-- 1 alexa alexa  444 Jun 26 12:48 known_hosts

知道这是什么原因造成的吗?

相关内容