博客
关于我
SecureCRT通过SSH连接虚拟机中的Linux系统(Ubuntu)
阅读量:204 次
发布时间:2019-02-28

本文共 950 字,大约阅读时间需要 3 分钟。

在尝试使用ssh username@localhost连接Ubuntu系统时,如果遇到ssh: connect to host localhost port 22: Connection refused的错误提示,通常是因为SSH服务未安装或未正确配置。以下是详细的解决步骤:

1. 安装SSH服务器

首先确保系统上已安装SSH服务器:

sudo apt-get install openssh-server

安装完成后,SSH服务会自动启动。

2. 检查SSH服务状态

确认SSH服务是否正在运行:

sudo systemctl status sshd

如果服务未启动,可以启动它:

sudo systemctl start sshd

或使用:

sudo service ssh start

3. 检查防火墙设置

有时防火墙会阻止SSH连接。关闭防火墙(仅限权限较高用户):

sudo ufw disable

检查防火墙状态:

sudo ufw status

如果防火墙开启,尝试禁用它后再次连接。

4. 检查用户权限

确保目标用户存在且具有登录权限:

sudo deluser usernamesudo adduser usernamesudo passwd username

或者使用用户管理工具如useraddpasswd

5. 检查SSH配置

查看/etc/ssh/sshd_config文件,确认配置正确:

  • 确保Listen 22存在且没有注释。
  • 确保Port 22正确无误。

6. 测试连接

尝试使用ssh username@localhostssh username@127.0.0.1

ssh username@localhost

如果仍有问题,检查网络是否阻止了22端口:

sudo iptables -L -n

清除防火墙规则并重启服务:

sudo iptables -Fsudo systemctl restart sshd

7. 使用SSH客户端工具

如果命令行连接不便,可以使用如PuTTYTerminal应用程序。

通过以上步骤,应该能够解决SSH连接被拒绝的问题。如果问题依旧,可以查看日志文件:

sudo tail -f /var/log/auth.log

转载地址:http://cuzi.baihongyu.com/

你可能感兴趣的文章
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>