发布时间:2015-02-02 18:33:01作者:知识屋
默认ssh端口为 22,总是被人扫描登录!
修改默认端口为2218的方法:
修改ssh配置文件 /etc/ssh/sshd_config,将里面的 Port 22前面的注释去掉,将22修改为 2218
[root@niche ~]# whereis sshssh: /usr/bin/ssh /etc/ssh /usr/share/man/man1/ssh.1.gz[root@niche ~]# cd /etc/ssh[root@niche ssh]# lltotal 272-rw------- 1 root root 242153 Jun 9 2014 moduli-rw-r--r-- 1 root root 2123 Dec 18 10:03 ssh_config-rw-r--r-- 1 root root 2123 Dec 18 09:55 ssh_config.bak-rw------- 1 root root 4443 Dec 18 10:02 sshd_config-rw-r----- 1 root ssh_keys 227 Dec 16 01:29 ssh_host_ecdsa_key-rw-r--r-- 1 root root 162 Dec 16 01:29 ssh_host_ecdsa_key.pub-rw-r----- 1 root ssh_keys 1679 Dec 16 01:29 ssh_host_rsa_key-rw-r--r-- 1 root root 382 Dec 16 01:29 ssh_host_rsa_key.pub[root@niche ssh]# nano sshd_config修改iptables 防火墙:/etc/sysconfig/iptables
#-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
改为
#-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 2218 -j ACCEPT
保存退出
重启iptables
[root@niche sysconfig]# systemctl stop iptables[root@niche sysconfig]# systemctl start iptables[root@niche sysconfig]# systemctl status iptablesiptables.service - IPv4 firewall with iptables Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled) Active: active (exited) since Thu 2014-12-18 10:11:13 EST; 5s ago Process: 24537 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS) Process: 24605 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS) Main PID: 24605 (code=exited, status=0/SUCCESS)Dec 18 10:11:13 niche systemd[1]: Starting IPv4 firewall with iptables...Dec 18 10:11:13 niche iptables.init[24605]: iptables: Applying firewall rule...]Dec 18 10:11:13 niche systemd[1]: Started IPv4 firewall with iptables.Hint: Some lines were ellipsized, use -l to show in full.
重启sshd
[root@niche sysconfig]# systemctl status sshdsshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Thu 2014-12-18 10:05:25 EST; 6min ago Process: 24469 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS) Main PID: 24470 (sshd) CGroup: /system.slice/sshd.service └─24470 /usr/sbin/sshd -DDec 18 10:05:25 niche systemd[1]: Starting OpenSSH server daemon...Dec 18 10:05:25 niche systemd[1]: Started OpenSSH server daemon.Dec 18 10:05:25 niche sshd[24470]: Server listening on 0.0.0.0 port 2271.Dec 18 10:05:25 niche sshd[24470]: Server listening on :: port 2271.Dec 18 10:06:20 niche sshd[24476]: Accepted password for root from 113.99.1...h2Dec 18 10:07:03 niche sshd[24503]: Accepted password for root from 113.99.1...h2Hint: Some lines were ellipsized, use -l to show in full.
linux一键安装web环境全攻略 在linux系统中怎么一键安装web环境方法
Linux网络基本网络配置方法介绍 如何配置Linux系统的网络方法
Linux下DNS服务器搭建详解 Linux下搭建DNS服务器和配置文件
对Linux进行详细的性能监控的方法 Linux 系统性能监控命令详解
linux系统root密码忘了怎么办 linux忘记root密码后找回密码的方法
Linux基本命令有哪些 Linux系统常用操作命令有哪些
Linux必学的网络操作命令 linux网络操作相关命令汇总
linux系统从入侵到提权的详细过程 linux入侵提权服务器方法技巧
linux系统怎么用命令切换用户登录 Linux切换用户的命令是什么
在linux中添加普通新用户登录 如何在Linux中添加一个新的用户
2012-07-10
CentOS 6.3安装(详细图解教程)
Linux怎么查看网卡驱动?Linux下查看网卡的驱动程序
centos修改主机名命令
Ubuntu或UbuntuKyKin14.04Unity桌面风格与Gnome桌面风格的切换
FEDORA 17中设置TIGERVNC远程访问
StartOS 5.0相关介绍,新型的Linux系统!
解决vSphere Client登录linux版vCenter失败
LINUX最新提权 Exploits Linux Kernel <= 2.6.37
nginx在网站中的7层转发功能