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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dongdong9223/article/details/81166835

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

Ingredient:

想在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

猜你喜欢

转载自blog.csdn.net/dongdong9223/article/details/81166835