SecureCRT连接Ubuntu报The remote system refused the connection.解决方案

使用SecureCRT连接到远程Ubuntu,连接失败报The remote system refused the connection.

进入Ubuntu系统,终端中敲入以下命令:

ps -ef|grep ssh

发现只有ssh-agent进程,而没有sshd进程,缺省情况下没有安装ssh-server

在终端中敲入以下命名安装openssh-server即可

sudo apt-get install openssh-server
安装过程如下,网络快的话两分钟左右,安装完毕后再次使用ps -ef|grep ssh命令查看sshd进程是否运行,如果正常运行使用SecureCRT重新尝试连接即可。
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libck-connector0 ncurses-term openssh-client openssh-sftp-server
  python-requests python-urllib3 ssh-import-id
Suggested packages:
  libpam-ssh keychain monkeysphere rssh molly-guard
The following NEW packages will be installed:
  libck-connector0 ncurses-term openssh-server openssh-sftp-server
  python-requests python-urllib3 ssh-import-id
The following packages will be upgraded:
  openssh-client
1 upgraded, 7 newly installed, 0 to remove and 264 not upgraded.
Need to get 1,279 kB of archives.
After this operation, 3,896 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libck-connector0 i386 0.4.5-3.1ubuntu2 [10.1 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kB]
Get:3 http://security.ubuntu.com/ubuntu/ trusty-security/main openssh-client i386 1:6.6p1-2ubuntu2.3 [576 kB]
Get:4 http://security.ubuntu.com/ubuntu/ trusty-security/main openssh-sftp-server i386 1:6.6p1-2ubuntu2.3 [35.6 kB]
Get:5 http://security.ubuntu.com/ubuntu/ trusty-security/main openssh-server i386 1:6.6p1-2ubuntu2.3 [324 kB]
Get:6 http://security.ubuntu.com/ubuntu/ trusty-security/main python-requests all 2.2.1-1ubuntu0.2 [43.0 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-urllib3 all 1.7.1-1build1 [38.9 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty/main ssh-import-id all 3.21-0ubuntu1 [9,624 B]
Fetched 1,279 kB in 1min 37s (13.2 kB/s)                                       
Preconfiguring packages ...
Selecting previously unselected package libck-connector0:i386.
(Reading database ... 169027 files and directories currently installed.)
Preparing to unpack .../libck-connector0_0.4.5-3.1ubuntu2_i386.deb ...
Unpacking libck-connector0:i386 (0.4.5-3.1ubuntu2) ...
Preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu2.3_i386.deb ...
Unpacking openssh-client (1:6.6p1-2ubuntu2.3) over (1:6.6p1-2ubuntu2) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ...
Unpacking ncurses-term (5.9+20140118-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu2.3_i386.deb ...
Unpacking openssh-sftp-server (1:6.6p1-2ubuntu2.3) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu2.3_i386.deb ...
Unpacking openssh-server (1:6.6p1-2ubuntu2.3) ...
Selecting previously unselected package python-urllib3.
Preparing to unpack .../python-urllib3_1.7.1-1build1_all.deb ...
Unpacking python-urllib3 (1.7.1-1build1) ...
Selecting previously unselected package python-requests.
Preparing to unpack .../python-requests_2.2.1-1ubuntu0.2_all.deb ...
Unpacking python-requests (2.2.1-1ubuntu0.2) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_3.21-0ubuntu1_all.deb ...
Unpacking ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
Setting up libck-connector0:i386 (0.4.5-3.1ubuntu2) ...
Setting up openssh-client (1:6.6p1-2ubuntu2.3) ...
Setting up ncurses-term (5.9+20140118-1ubuntu1) ...
Setting up openssh-sftp-server (1:6.6p1-2ubuntu2.3) ...
Setting up openssh-server (1:6.6p1-2ubuntu2.3) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh start/running, process 5002
Setting up python-urllib3 (1.7.1-1build1) ...
Setting up python-requests (2.2.1-1ubuntu0.2) ...
Setting up ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...



转载于:https://www.cnblogs.com/lanzhi/p/6468475.html

<think>我们正在解决SecureCRT连接远程系统时出现"connection refused"错误的问题。 根据引用[1]中的经验,即使已经安装了ssh并开放了22端口,仍可能出现连接拒绝。引用[1]的作者通过重置VMware虚拟网络设置解决了问题。 另外,引用[2]提到了expect(一种自动化交互的工具)的安装依赖,但这不是当前问题的重点。 用户的问题:SecureCRT remote connection refused fix 解决步骤: 1. 确认网络连通性:首先确保本地机器可以ping通远程服务器(如果是虚拟机,则确保主机能ping通虚拟机)。 2. 检查远程服务器的SSH服务状态:确保远程服务器上SSH服务已安装并正在运行。 3. 检查防火墙设置:确保远程服务器的防火墙允许22端口(或自定义的SSH端口)的访问。 4. 检查SSH配置:检查远程服务器的SSH配置文件(/etc/ssh/sshd_config)是否正确,特别是监听端口和允许的协议。 5. 检查IP地址和端口:确保在SecureCRT中输入的IP地址和端口号正确。 6. 如果上述步骤都正常,但问题仍然存在,考虑重置虚拟网络设置(如果是VMware虚拟机)。 具体操作: 步骤1:检查网络连通性 在本地命令行中执行:`ping <远程服务器IP>` 如果ping不通,检查网络配置(如VMware的网络连接模式,虚拟机IP配置等)。 步骤2:检查SSH服务状态 在远程服务器上(如果是Linux): 检查SSH服务状态:`sudo systemctl status sshd` 或 `sudo service ssh status` 如果没有运行,启动服务:`sudo systemctl start sshd` 或 `sudo service ssh start` 确保开机启动:`sudo systemctl enable sshd` 步骤3:检查防火墙 在远程服务器上(以Ubuntu为例): 查看防火墙状态:`sudo ufw status` 如果防火墙开启,确保22端口开放:`sudo ufw allow 22` 如果之前没有开启防火墙,可以尝试启用防火墙并开放22端口(如引用[1]所示): `sudo ufw enable` `sudo ufw allow 22` 步骤4:检查SSH配置 编辑SSH配置文件:`sudo vi /etc/ssh/sshd_config` 确保以下配置: Port 22 ListenAddress 0.0.0.0 # 或者服务器的IP Protocol 2 PermitRootLogin yes # 根据安全需求,可以设置为no,但测试时可以先允许 修改配置后重启SSH服务:`sudo systemctl restart sshd` 步骤5:检查SecureCRT设置 在SecureCRT中,确保连接配置的IP地址和端口号正确(默认为22端口)。 步骤6:重置虚拟网络(如果是VMware虚拟机) 如果上述步骤都正确,但问题依旧,尝试重置VMware虚拟网络: 打开VMware -> 编辑 -> 虚拟网络编辑器 -> 点击“更改设置”(需要管理员权限)-> 点击“还原默认设置” 还原后,重新配置虚拟机的网络适配器(可能需要重新设置网络连接模式,如NAT或桥接),并重新获取IP地址。 如果问题仍然存在,可能需要检查其他因素,如是否被远程服务器的hosts.deny文件拒绝,或者是否有其他安全组(如云服务的安全组)阻止了连接。 注意:引用[1]中提到了重置VMware虚拟网络后解决了问题,所以如果用户使用的是VMware虚拟机,可以尝试此方法。 生成相关问题: 1. 如何检查Linux上的SSH服务是否运行? 2. 如何在Ubuntu上配置防火墙规则? 3. VMware虚拟机的网络模式(NAT、桥接等)有什么区别?</think>针对 SecureCRT 连接远程系统时出现 "Connection refused" 的问题,请按以下步骤排查: --- ### **1. 检查网络连通性** - 在本地终端执行 `ping <远程IP>` 确认网络可达 ```bash ping 192.168.1.100 # 替换为你的远程IP ``` - 若不通: - 虚拟机用户:检查 VMware 网络模式(建议 **桥接/NAT 模式**) - 云服务器用户:检查安全组是否放行 ICMP 协议 --- ### **2. 验证 SSH 服务状态** 在远程服务器上执行: ```bash sudo systemctl status sshd # 检查 SSH 服务状态 sudo systemctl start sshd # 若未运行则启动服务 sudo systemctl enable sshd # 设置开机自启 ``` --- ### **3. 检查防火墙规则** 在远程服务器操作: ```bash sudo ufw status # 查看防火墙状态 sudo ufw allow 22 # 开放 22 端口(SSH默认端口) sudo ufw enable # 启用防火墙(若未启用) ``` > 提示:云服务器需额外在**云平台安全组**中放行 22 端口[^1]。 --- ### **4. 检查 SSH 配置** 编辑配置文件: ```bash sudo vi /etc/ssh/sshd_config ``` 确认以下参数: ```ini Port 22 # 监听端口 ListenAddress 0.0.0.0 # 监听所有IP PermitRootLogin yes # 允许root登录(测试时可临时开启) ``` 保存后重启服务: ```bash sudo systemctl restart sshd ``` --- ### **5. 虚拟机特殊处理(VMware)** 若为虚拟机: 1. 打开 **VMware > 编辑 > 虚拟网络编辑器** 2. 点击 **"还原默认设置"**(需管理员权限)[^1] 3. 重启虚拟机获取新 IP --- ### **6. SecureCRT 设置验证** 在 SecureCRT 中检查: - 正确输入 **IP 地址和端口**(默认 22) - 连接协议选择 **SSH2** - 取消勾选 **"GSSAPI" 认证**(位置:Options > SSH > Authentication) --- ### **7. 高级排查** 若仍失败: ```bash # 在远程服务器调试 SSH 日志 sudo tail -f /var/log/auth.log # Ubuntu/Debian sudo tail -f /var/log/secure # CentOS/RHEL # 本地测试连接 telnet <远程IP> 22 # 应返回 SSH 协议信息 ``` --- **常见原因总结**: - 🔥 防火墙阻塞 22 端口(占 70% 案例) - 🚫 SSH 服务未运行 - 🌐 虚拟机网络配置异常 - ⚙️ SSH 配置文件错误 > 若所有步骤无效,尝试临时关闭远程服务器防火墙测试:`sudo ufw disable`(测试后请重新启用)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值