博客
关于我
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/

你可能感兴趣的文章
postgres--vacuum
查看>>
postgres--wal
查看>>
postgres--流复制
查看>>
postgres10配置huge_pages
查看>>
PostgreSQL 10.0 preview 变化 - pg_xlog,pg_clog,pg_log目录更名为pg_wal,pg_xact,log
查看>>
PostgreSQL 10.1 手册_部分 II. SQL 语言_第 15章 并行查询_15.2. 何时会用到并行查询?...
查看>>
PostgreSQL 10.1 手册_部分 II. SQL 语言_第 9 章 函数和操作符_9.23. 行和数组比较
查看>>
PostgreSQL 10.1 手册_部分 III. 服务器管理_第 21 章 数据库角色
查看>>
Postgresql 12.9如何配置允许远程连接
查看>>
PostgreSQL 9.6 同步多副本 与 remote_apply事务同步级别 应用场景分析
查看>>
Postgresql CopyManager 流式批量数据入库
查看>>
PostgreSQL cube 插件 - 多维空间对象
查看>>
PostgreSQL Daily Maintenance - cluster table
查看>>
PostgreSQL on Linux 最佳部署手册
查看>>
PostgreSQL Oracle 兼容性之 - pipelined
查看>>
PostgreSQL Point-In-Time Recovery (Incremental Backup)
查看>>
postgresql Streaming Replication监控与注意事项
查看>>
postgresql 不需要付费_使用数据传输在PostgreSQL执行 外部连接运算符
查看>>
postgresql 主从配置_生产环境postgresql主从环境配置
查看>>
postgresql 函数&存储过程 ; 递归查询
查看>>