ssh 安装及登录提示:connection refused的解决办法

溪西创客小屋

原文出处:http://hi.baidu.com/leejun_2005/blog/item/fbc27c4b20e83d3a08f7ef23.html?timeStamp=1309179713928

from:http://hi.baidu.com/tunaisen/blog/item/85e0a41805ed9fb24bedbcf3.html

如果出现ssh: connect to host XX.XX.XX.XX port 22: Connection refused

请按如下步骤检查:

1、目标主机的ssh server端程序是否安装、服务是否启动,是否在侦听22端口;

检查方法:

june@ubuntu:~$ ps-ef|grep sshd

root      2859     1  020:29?        00:00:00 /usr/sbin/sshd -D

root      2901  2859  020:31?        00:00:00 sshd:june[priv]

june      2971  2901  020:31?        00:00:00 sshd:june@pts/1

june@ubuntu:~$

其中/usr/sbin/sshd为ssh clinet/server中server端的守护进程,如果上述结果中没有sshd出现,那么可能就是你的server端程序没有安装(Ubuntu11.04 默认没有安装ssh server,只安装了sshclient),或者sshd服务没有启动,这两者的解决办法请见下文详述。
2、是否允许该用户登录;
3、本机是否设置了iptables规则,禁止了ssh的连入/连出;

检查方法:

june@ubuntu:~$sudo  iptables-L

[sudo] password for june:

Chain INPUT (policy ACCEPT)

target    prot optsource               destination

ACCEPT    tcp  --  anywhere             anywhere            tcpdpt:ssh

Chain FORWARD (policy ACCEPT)

target    prot opt source              destination

Chain OUTPUT (policy ACCEPT)

target    prot optsource              destination

june@ubuntu:~$
4、查查ssh的配置文件

ls -lrt /etc/ssh

针对第一点没有安装ssh server或者没开启sshd的用户,可以参考这篇:

Ubuntu如何开启SSH服务

SSH分客户端openssh-client和openssh-server
  如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-get install openssh-client),如果要使本机开放SSH服务就需要安装openssh-server:sudo apt-get install openssh-server然后确认sshserver是否启动了:
ps -e |grep ssh
  如果看到sshd那说明ssh-server已经启动了。
  如果没有则可以这样启动:sudo /etc/init.d/ssh start
ssh-server配置文件位于/etc/ssh/sshd_config,在这里可以定义SSH的服务端口,默认端口是22,你可以自己定义成其他端口号,如222。
  然后重启SSH服务:
sudo /etc/init.d/ssh stop
sudo /etc/init.d/ssh start
  然后使用以下方式登陆SSH:
ssh tuns@192.168.0.100    tuns为192.168.0.100机器上的用户名,需要输入密码。
  断开连接:exit

ssh 安装及登录提示:connection refused(ssh: connect to host XX.XX.XX.XX port 22: Connection refused)的解决办法相关推荐

  1. Windows登录虚拟机Ubuntu系统登录不成功解决办法(ssh: connect to host 192.168.220.128 port 22: Connection refused)

    我在windows端第一次连接自己电脑虚拟机建立的Ubuntu系统时出现如下问题 ssh: connect to host 192.168.220.128 port 22: Connection re ...

  2. 可以ping通 但ssh: connect to host 192.168.0.2 port 22: Connection refused

    目录 问题描述 原因 解决 问题描述 自己在树莓派端通过SCP指令给电脑上ubuntu传输文件发现提示:ssh: connect to host 192.168.0.2 port 22: Connec ...

  3. ssh连接服务器出现:ssh: connect to host 192.168.1.107 port 22: Connection refused 的解决方法

    文章目录: 1 说明遇到问题场景 2 解决方式 1 说明遇到问题场景 1.我的系统环境 windows10 连接的服务器系统为:Mint19.3 2.我使用windows,在局域网下通过ssh连接服务 ...

  4. ssh: connect to host 192.168.101.34 port 22: Connection timed out

    背景: 使用 Cygwin64 登录虚拟机时发现无法远程登录虚拟机中Ubuntu系统(之前可以): $ ssh lc@192.168.101.34 ssh: connect to host 192.1 ...

  5. connect to host xxx.xxx.xxx.xxx port 22: Connection refused

    connect to host xxx.xxx.xxx.xxx port 22: Connection refused 问题:win10使用ssh远程登录VMWare虚拟机上安装的Ubantu系统时连 ...

  6. LINUX开启ssh服务,报错:ssh: connect to host 192.168.0.101 port 22: Connection refused

    Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...

  7. LINUX开启ssh服务,报错:ssh: connect to host 192.168.6.129 port 22: Connection refused

    Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因 ...

  8. ssh 错误 ssh: connect to host 192.168.1.106 port 22: Connection refused

    感谢这篇文字的主人:http://asyty.iteye.com/blog/1440141 Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host ...

  9. ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection refused

    问题描述: 我在尝试通过 SSH 连接到目标服务器时遇到了问题.具体地说,当我尝试使用 SSH 客户端连接到服务器的 IP 地址时,出现了 "ssh: connect to host [IP ...

  10. GIT 远程仓库更换ip,导致本地拉取代码报错:ssh: connect to host 192.xxx.0.xxx port 22: Connection timed out fatal: Coul

    目录 报错信息 问题产生背景 解决方案 报错信息 git pull origin 1.0.0-develop ssh: connect to host xxx.xxxx.xx.xxx port 22: ...

最新文章

  1. python从入门到精通书-Python从入门到精通(资源汇总)
  2. 用word发CSDN blog,免去插图片的烦恼
  3. mpc 安全多方计算协议_BNC公链 | 不看到数据却能进行计算?一文了解安全多方计算...
  4. 大人的世界啊,全是屁股!
  5. Nginx的location区块的作用及设置
  6. fpga 输入信号除了1和0还有别的状态?
  7. 【目标检测】目标检测中的多尺度检测(Multi-Scale),FPN,RPN
  8. git push :unable to write sha1 filename ./bojects/xxxx:权限不够
  9. springboot集成阿里云直播,低延时直播
  10. 抗渗等级p6是什么意思_混凝土防水等级S6,P6分别是什么意思
  11. vscode中怎样格式化js代码_vsCode配置代码格式化
  12. 经典算法之直接插入排序法
  13. 3D Touch介绍:电子秤App与快捷操作
  14. win32编程的经典书籍
  15. LeetCode376 摇摆序列
  16. HTML+CSS+JS制作【俄罗斯方块】小游戏
  17. Spark on YARN - Clinet模式运行spark报错问题
  18. SDUSTOJ1670 Problem C: 农夫果园
  19. Sql 判断日期是否在本月内
  20. APS期刊投稿准备: REVTex格式

热门文章

  1. web前端常用快捷键
  2. 航空航天大类C语言程设第三次练习赛
  3. 【离散数学】测试一 命题逻辑
  4. OC11_Block
  5. 小程序实战 -- 仿网易蜗牛读书
  6. 湖北生态工程职业技术学院信息机电学院智慧林业物联网实训室竣工
  7. FFMPEG 深入浅出
  8. 2022年陕西省中高级工程师职称评审晋级条件和流程
  9. Linux shell 常用代码片断
  10. Android app开发 如何添加启动界面