CentOS7开启SSH连接

1、先确定虚拟机是否装了openssh-server,执行 yum list installed |grep openssh-server 查看是否安装

这里显示已经安装,如果没有任何输出表示没有安装 , 执行 yum install openssh-server 命令安装

2、确定安装之后修改配置文件 vim /etc/ssh/sshd_config 

开启端口

 允许root用户登录

开启用户名密码验证登录

 保存退出

3、开启服务

systemctl start sshd.service

4、查看服务状态

systemctl status sshd.service

这里是已启动,查看端口监听状态 netstat -lnpt |grep 22 

5、连接

先使用命令 ifconfig 查看当前ip地址,出现 command not found 使用 yum -y install net-tools 安装

这里用的是Xshell

 

 

6、其他操作命令

systemctl enable sshd.service      #设置开机自启
systemctl stop sshd.service        #停止
systemctl restart sshd.service     #重启
原文地址:https://www.cnblogs.com/-wei/p/15219242.html