使用Docker操作“ssh localhost”时出现“connect to host localhost port 22: Connection refused”问题的解决

转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/81166835
本文出自【我是干勾鱼的博客】

Ingredient:

  • Docker Store:Image Ubuntu(Docker Store)

  • Hadoop:hadoop-2.9.1.tar.gz(Apache Hadoop Releases Downloads, All previous releases of Hadoop are available from the Apache release archive site)

  • Hadoop Setting Up:Hadoop: Setting up a Single Node Cluster

想在Docker容器中安装Hadoop,设置系统无密码登录时,配置了公钥私钥之后,操作:

ssh localhost

却仍然报错:

root@becdadab2db1:/# ssh localhost
ssh: connect to host localhost port 22: Connection refused

后来发现竟然是没有开ssh服务。虽然ssh可以连接别的服务器,但那是使用的ssh客户端,而被连接时就要使用服务器了。使用命令查看一下:

ps -e | grep ssh

可以查看一下状态:

root@becdadab2db1:/# /etc/init.d/ssh status
 * sshd is not running

如果没有就启动一下服务器:

root@becdadab2db1:/# /etc/init.d/ssh start 
 * Starting OpenBSD Secure Shell server sshd  

然后在进行:

ssh localhost

操作就成功了!

参考:

Hadoop系列之(一):Hadoop单机部署

Ubuntu下 ssh : connect to host localhost port 22:Connection refused

你可能感兴趣的:(Docker)