侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

CentOS7 防火墙设置

2023-12-03 星期日 / 0 评论 / 0 点赞 / 75 阅读 / 1871 字

CentOS 7 默认使用的是firewall作为防火墙,这里改为iptables防火墙。关闭 firewalld# 查看 firewalld 进程是否启动了[root@localhost ~]# p

CentOS 7 默认使用的是firewall作为防火墙,这里改为iptables防火墙。

关闭 firewalld

# 查看 firewalld 进程是否启动了[root@localhost ~]# ps aux | grep firewalldroot        943  0.0  0.1 327172 26756 ?        Ssl  06:09   0:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopidroot      51669  0.0  0.0 112668   972 pts/0    S+   20:45   0:00 grep --color=auto firewalld# 停止 firewalld[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# ps aux | grep firewalldroot      51728  0.0  0.0 112664   972 pts/0    S+   20:45   0:00 grep --color=auto firewalld# 禁止firewall开机启动[root@localhost ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

安装iptables防火墙

yum updateyum install -y vim openssl openssh-server net-toolsyum install iptables-services# ...# 编辑防火墙配置文件vim /etc/sysconfig/iptables# 保存退出:wq! # 最后重启防火墙使配置生效systemctl restart iptables.service# 查看防火墙运行状态systemctl status iptables# 设置防火墙开机启动systemctl enable iptables.service

修改配置文件

vim /etc/ssh/sshd_config将 PermitRootLogin,RSAAuthentication,PubkeyAuthentication 的设置打开。

# Authentication:#LoginGraceTime 2mPermitRootLogin yes#StrictModes yes#MaxAuthTries 6#MaxSessions 10RSAAuthentication yesPubkeyAuthentication yes

启动ssh的服务:

systemctl start sshd.service# orservice sshd restart# or/usr/bin/ssh-keygen -A/usr/sbin/sshd

设置开机自动启动ssh服务

systemctl enable sshd.service

广告 广告

评论区