如果有说错的地方希望大神指正
ssh连接VirtualBox中的CentOSssh连接VirtualBox中的CentOS
0.我的配置1.ssh-server2.虚拟机端口映射3.windows防火墙设置4.ssh连接 0.我的配置
VirtualBox6.1CentOS Stream release 8,安装时选择的是安装服务器(不需要图形化但也不是最小安装)
cat /etc/redhat-release
没有说用cmd或者powershell则都是在虚拟机中进行操作没有说用cmd或者powershell则都是在虚拟机中进行操作没有说用cmd或者powershell则都是在虚拟机中进行操作时间:2022/2/8 1.ssh-server
安装
查看ssh安装情况
rpm -qa | grep ssh
安装openssh-server
yum install openssh-server
配置
vim /etc/ssh/sshd_config
找到Port 22解注释
找到PermitRootLogin确认是yes
开启ssh查看ssh状态开机启动ssh
systemctl start sshd.service systemctl status sshd.service systemctl enable sshd.service
查看22端口,若出现LISTEN则已经开放监听,没有开放的话关掉防火墙试试
netstat -an | grep 222.虚拟机端口映射
VirtualBox>设备>网络>网络…>端口转发
如下添加一条配置,主机ip可以不填,子系统ip通过ifconfig获取
管理员运行cmd或者powershell,都返回确定则成功
强制添加入站规则
netsh advfirewall firewall add rule name="SGAccessInboundRule" dir=in protocol=tcp action=allow localport=22
强制添加出站规则
netsh advfirewall firewall add rule name="SGAccessOutboundRule" dir=out protocol=tcp action=allow remoteport=224.ssh连接
在cmd或者powershell中ipconfig找到VirtualBox Host-only Network的IPv4地址
ssh root@IPv4地址
结束



