我有 VirtualBox Linux 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux。
我已经安装了 LXD 3.x linux 容器我已经在它们上面创建了三个 ubuntu 类型容器的实例:
+------+---------+----------------------+
| NAME | STATE | IPV4 |
+------+---------+----------------------+
| db1 | RUNNING | 10.81.188.179 (eth0) |
+------+---------+----------------------+
| web1 | RUNNING | 10.81.188.27 (eth0) |
+------+---------+----------------------+
| web2 | RUNNING | 10.81.188.7 (eth0) |
+------+---------+----------------------+
在尝试建立到 db1 服务器的 ssh 连接。我在主机 env 上执行了以下设置:
我运行了 ssh-keygen ,结果如下:
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
我已像这样附加到“db1”实例:
sudo lxc exec db1 /bin/bash
然后我在 db1 框上导航到该/etc/ssh/sshd_config
文件并设置了PasswordAuthentication yes
参数,然后我重新启动了 lxc 实例
回到主机节点,我尝试使用以下命令在远程访客节点上复制/设置公钥:
ssh-copy-id -i ~/id_rsa.pub james@10.81.188.179, and
ssh-copy-id -i ~/id_rsa.pub 10.81.188.179
……都失败了。这是日志:
james@james-virtualbox:~/.ssh$ ssh-copy-id -i ~/.ssh/id_rsa.pub james@10.81.188.179
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/james/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
james@10.81.188.179: Permission denied (publickey).
为什么不将该密钥添加到远程 db1 机器...?!