A-A+
CentOS修改远程连接端口号的方法
操作系统:CentOS
远程连接工具:SecureCRT
实验任务:CentOS 6.0修改ssh远程连接端口
实验步骤:
1)添加9899端口的方式如下:
a)方式一:
- [root@www ~]# vi /etc/sysconfig/iptables #在该文件中添加下面语句;
- -A INPUT -p tcp -m state --state NEW -m tcp --dport 9899 -j ACCEPT
- [root@www ~]# /etc/init.d/iptables restart
b)方式二:
- [root@www ~]# iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 9899 -j ACCEPT
- [root@www ~]# /etc/init.d/iptables save
- [root@www ~]# /etc/init.d/iptables restart
2)修改ssh端口配置文件
- [root@www ~]# vi /etc/ssh/sshd_config
在端口#Port 22下面增加Port 9899
- #Port 22
- Port 9899
- [root@www ~]# service sshd restart
3)远程连接CentOS
4)禁止root通过ssh远程登录
- [root@www ~]# vi /etc/ssh/sshd_config
- PermitRootLogin yes 改成PermitRootLogin no,并把前面的注释#取消,这样root就不能远程登录了!可以用普通账号登录进去,要用到root的时候使用命令su root 切换到root账户。
- #PermitRootLogin yes
- PermitRootLogin no