Modifying ssh port in the CentOS6. What the engine finds is often not very comprehensive, so I record it for reference and copy the relevant commands when making modifications, so as not to have to look for them every time. The article was tested on two KVM hosts, HostYun and 80VPS.
1. Modify the configuration file to add a new port
[[email protected] ~]# vi /etc/ssh/sshd_config
Find #Port 22, remove the # in front and add a new line Port xxxx (xxxx refers to the new port), then save and exit.
2. Firewall release port
[[email protected] ~]# firewall-cmd --zone=public --add-port=2322/tcp --permanent #2322指新的端口 [[email protected] ~]# firewall-cmd –reload
If our firewall is turned off, this step can be ignored, but it is still turned on.
3. Turn off SElinux
[[email protected] ~]# vi /etc/selinux/config
The main purpose here is to modify SELINUX=enforcing to SELINUX=disabled, save and restart after completion.
***This step can also be done by adding an ssh port to SELinux instead of closing SELINUX directly. The specific steps are as follows.
[[email protected] ~]# yum provides semanage #安装管理工具 [[email protected] ~]#yum -y install policycoreutils-python #安装依赖包 [[email protected] ~]#semanage port -l | grep ssh #查询ssh端口 [[email protected] ~]#semanage port -a -t ssh_port_t -p tcp 2322 #向SELinux中添加ssh端口 [[email protected] ~]#systemctl restart sshd.service #重启sshd服务window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":["mshare","kaixin001","tsina"," tsohu","tqq","renren","qzone","weixin","bdysc","bdxc","tqf","tieba","douban","bdhome","sqq","thx" ],"bdPic":"","bdStyle":"0","bdSize":"24"},"slide":{"type":"slide","bdImg":"2","bdPos" :"left","bdTop":"100"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["tsina","tqq","tsohu","qzone","renren", "weixin","mshare"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg .share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];