Linux 上SSH 服务的配置和管理

0.前期准备:清空防火墙,关闭SELinux。

1 [root@localhost ~]# iptables -F    #清空防火墙
2 [root@localhost ~]# /etc/init.d/iptables save      #保存防火墙状态
3 iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]
4 
5 [root@localhost ~]# vi /etc/selinux/config   #编辑SELinux配置文件
6 #SELINUX=enforcing
7 SELINUX=disabled      # 改成disabled
8 reboot #重启
9 getenforce #查看状态是否关闭

1.检查一下默认安装的系统是否安装了SSH服务:

1 [root@localhost ~]# chkconfig --list | grep sshd
sshd           0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

2.首先要备份配置文件,任何时候我们需要修改配置文件的时候都建议先把原始文件备份

[root@localhost ~]# cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.bak  #sshd是服务器端的配置文件  ssh是客户端的配置文件

3.下面我们就来修改SSHD_config配置文件,需要修改两个地方,首先们需要开放SSH用到的      22端口,把下图中前面的#号去掉即可 可改成自己的端口号。

4.第二个需要修改的地方是PermitRootLogin yes这个是否允许超级管理员远程登录,同样的我们把前面的#号去掉即可:

Port 3600
PermitRootLogin yes

 5.重启SSH服务

service sshd restart
原文地址:https://www.cnblogs.com/sunshine-long/p/8845881.html