添加新用户并安装ssh后,使用ssh连接到容器

时间:2016-12-07 00:16:15

标签: docker ssh

我正在努力将ssh放入容器中。执行后 在docker run -p 22:22 --network=host -it ubuntu:14.04之后adduser admin并在我的基于ubuntu的映像中安装ssh我打开了一个新的docker终端并解雇ssh username@${hostip}但是我的添加用户拒绝连接。谢谢你的帮助

已修改

docker0   Link encap:Ethernet  HWaddr 02:42:fe:c4:aa:ea
      inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
      inet6 addr: fe80::42:feff:fec4:aaea/64 Scope:Link
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:536573 errors:0 dropped:0 overruns:0 frame:0
      TX packets:596145 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:21717921 (21.7 MB)  TX bytes:945577957 (945.5 MB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:4e:1a:70
      inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
      inet6 addr: fe80::a00:27ff:fe4e:1a70/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1674522 errors:0 dropped:0 overruns:0 frame:0
      TX packets:781497 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:1431596796 (1.4 GB)  TX bytes:47605814 (47.6 MB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:c7:b0:50
      inet addr:192.168.99.106  Bcast:192.168.99.255  Mask:255.255.255.0
      inet6 addr: fe80::a00:27ff:fec7:b050/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:6326489 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1012444 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:8806794970 (8.8 GB)  TX bytes:1868661107 (1.8 GB)

lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:94 errors:0 dropped:0 overruns:0 frame:0
      TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1
      RX bytes:14064 (14.0 KB)  TX bytes:14064 (14.0 KB)

docker ps输出

CONTAINER ID        IMAGE               COMMAND             CREATED               STATUS              PORTS               NAMES
6851d647642c        ubuntu:14.04        "/bin/bash"         About an hour ago   Up 31 minutes                           stoic_jang

我还使用apt-get install ssh安装了ssh,不确定它是不是正确的包。

0 个答案:

没有答案