我有一个CentOS 6.4实例。如何从centos 6.4 ssh到没有密码的码头容器?
在此实例中,我无法将RSA密钥ssh ssh转换为基于CentOS 6.7的Docker容器。
在Ubuntu(Trusty)和Amazon Linux实例上,我可以SSH入Docker容器。
我需要使用ssh命令(真正可行)而不是docker exec
。
我正在运行的命令是ssh -i id_rsa -p 2200 [email protected]
。
我Dockerfile看起来像这样:
From centos:6.7
#update yum repository and install openssh server
RUN yum update -y
RUN yum install -y openssh-server
RUN yum install -y sudo
RUN useradd user
RUN echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN mkdir -p /home/user/.ssh
ADD id_rsa.pub /home/user/.ssh/authorized_keys
RUN chown user /home/user/.ssh -R
RUN chmod 600 /home/user/.ssh/authorized_keys
#generate ssh key
RUN ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key
EXPOSE 22
CMD ["sh","-c","/usr/sbin/sshd -D;sleep 1"]
我已经检查的权限上的所有文件(私钥和公钥,authorized_keys文件)和目录(/.ssh)。
事实上,我可以ssh亚马逊Linux到这个容器让我相信这个问题不是来自我的码头容器,也没有文件和文件夹的权限。
我已经更改了Docker容器和本地CentOS上的PAM。
我已经更新了Python到2.7.12(因为这真的是为了......不管)。
容器正在运行。
我已经删除了known_hosts。
使用ssh配置。
当添加-vvvvv
我ssh
命令我得到这个问题:
debug3: Not a RSA1 key file /path/to/project/dir/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
我将此添加到我的Dockerfile:'RUN SED -i 'S/UsePAM是/ UsePAM没有/ G' 的/ etc/SSH/sshd_config中 运行yum安装的passwd -y 通过运行passwd -f -u centos' –