[VirtualBox]windows 无法通过SSH访问虚拟机

一、设置网络连接

设置网络连接为"桥接方式",这样在虚拟机中就可以直接连接外网。

[VirtualBox]windows 无法通过SSH访问虚拟机

[VirtualBox]windows 无法通过SSH访问虚拟机

二、启动linux虚拟系统,启动sshd服务(suse系统)

修改sshd配置

vi /etc/ssh/sshd_config命令修改sshd配置

配置sshd监听端口

[VirtualBox]windows 无法通过SSH访问虚拟机

配置允许root账号登录

去除PermitRootLogin no前的“#“符号,是配置项生效

[VirtualBox]windows 无法通过SSH访问虚拟机

启动sshd服务

service sshd start命令启动

确认sshd服务启动状态

[VirtualBox]windows 无法通过SSH访问虚拟机

sshd端口是否启动监听状态

22端口是sshd端口,从图可以确认端口已经打开,状态是监听状态

[VirtualBox]windows 无法通过SSH访问虚拟机

三、linux虚拟系统防火墙

linux默认会启动防火墙,防火墙规则为空表示禁止访问,需要关闭防火墙或配置访问规则

关闭方法

yast命令打开配置界面

[VirtualBox]windows 无法通过SSH访问虚拟机

[VirtualBox]windows 无法通过SSH访问虚拟机

选择“下一步”->“完成”

[VirtualBox]windows 无法通过SSH访问虚拟机

四、通过SSH访问linux虚拟系统

确认系统IP

[VirtualBox]windows 无法通过SSH访问虚拟机

建立CRT链接

使用SSH2

[VirtualBox]windows 无法通过SSH访问虚拟机

Hostname使用linux虚拟机的IP地址,22是ssh配置的端口,Username为linux虚拟机登录账号

[VirtualBox]windows 无法通过SSH访问虚拟机

完成

[VirtualBox]windows 无法通过SSH访问虚拟机

测试

[VirtualBox]windows 无法通过SSH访问虚拟机

根据提示输入root登录密码

[VirtualBox]windows 无法通过SSH访问虚拟机

测试成功

[VirtualBox]windows 无法通过SSH访问虚拟机