如何scp自我?

如何scp自我?

我想从我自己到我自己进行 scp,但出现Permission denied (publickey)错误。这更多的是脚本的边缘情况,但我觉得它不应该有问题。

ifconfig | grep inet
# 192.168.11.151

scp -p myport [email protected]:/opt/some-files .

# My public key exists and is valid enough to reach out to GitHub
cd ~/.ssh
less id_rsa
less id_rsa.pub
less authorized_keys

答案1

最常见的问题是忘记正确设置权限:

chmod -R 600 ~/.ssh

答案2

尝试这个:

使用同一用户创建您的.pub文件。

user:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
f1:f2:f3:f4:f5:f6:f7:f8:f9:f0:f1:f2:f3:f4:f5:f6 user@host
The key's randomart image is:
+--[ RSA 2048]----+
|        o+=.. E  |
|       . ++=..   |
|        +.*oo.   |
|       . O.+. o  |
|        S .o.. . |
|          . .    |
|                 |
|                 |
|                 |
+-----------------+
user:~$ 

将密钥插入authorized_keys文件中

user:~$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

再次转移

user:~$ scp user@localhost:/opt/some-files .

试一下!

相关内容