一、Centos 7 修改SSH端口号

1、修改/etc/ssh/sshd_config

vi /etc/ssh/sshd_config

#Port 22         在这行下添加下面这行

Port 7156      //下面添加这一行


2、修改SELinux

使用以下命令查看当前SElinux 允许的ssh端口:

安装semanage,

yum -y install policycoreutils-python

semanage port -a -t ssh_port_t -p tcp 7156


然后确认一下是否添加进去

semanage port -l | grep ssh

如果成功会输出

ssh_port_t                    tcp    7156, 22


3、重启ssh

systemctl restart sshd  (systemctl restart sshd.service)


4、firewall开放ssh端口

yum -y install firewalld;

systemctl enable firewalld; 

systemctl start firewalld;   //安装启动 firewall

firewall-cmd --zone=public --add-port=7156/tcp --permanent

firewall-cmd --reload

firewall-cmd --list-all-zones |grep 7156     //查看结果


二、无 ifconfig命令,可用yum search ifconfig 查询包

yum -y install net-tools


三、hostname保存目录

/etc/hostname