1 linux ssh 更改端口号:
更改端口号是通过修改SSH的配置文件实现的,登录ssh后,输入
1 |
vim /etc/ssh/sshd_config |
向下找到#Port 22这段 先重新建一个Port 22222(最好大于10000 最大不能超过65535)保存退出。
在输入
1 |
/etc/init.d/sshd restart |
重启ssh服务,这样SSH端口将同时工作与22和22222上,退出ssh,然后使用22222端口登录,看是否可以连接成功,连接成功后在删除22端口(保存22端口是避免网络原因,登录不上)
登陆时显示no route to host解决方法
no route to host出现这个,一般是服务器安装了防火墙,将将端口添加到防火墙规则即可
1 |
rpm -qa| grep iptables #查看是否安装了iptables防火墙 |
如果安装了,编辑防火墙配置文件
1 |
vi /etc/sysconfig/iptables |
2 |
#增加的规则(端口号改为自己的,禁止22端口登陆也可以在这里将22端口的规则删除) |
3 |
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21578 -j ACCEPT |
4 |
service iptables restart #重启防火墙 |
2. 修改root 密码: passwd root
3. vsftp 限制IP访问方法
修改/etc/hosts.deny 加入vsftpd : ALL
修改/etc/hosts.allow 修改后会即时生效的
加入vsftpd:.admin99.net
vsftpd:192.168.0.
vsftpd:192.168.0.0/255.255.255.0
第一行表示,只有admin99.net这个域里的主机允许访问vsftpd服务,注意admin99.net前面的那个点(.);
第二行表示,只有192.168.0这个网段的用户允许访问vsftpd服务,注意0后面的点(.);
第三行表示,只有192.168.0这个网段的用户允许访问vsftpd服务,注意这里不能写为192.168.0.0/24。
vsftpd服务是由xinetd管理的话,可以修改/etc/xinetd.d/
/vsftpd配置文件,加入only_from = ip段即可。
附录:
1、修改文件:/etc/hosts.deny,加上最后两行,阻止所以进入,如下:
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:ALL
vsftpd:ALL
2、修改 /etc/hosts.allow,加上允许访问的IP,如下:
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
#sshd
sshd:192.168.0.125
sshd:192.168.0.126
3. kill -HUP pid pid 是进程标识。如果想要更改配置而不需停止并重新启动服务
4. 校准linux服务器时间 /usr/sbin/ntpdate 210.72.145.44
6. grep -v grep “grep -v grep”是在列出的进程中去除含有关键字“grep”的进程。-v 取反命令 -wc 计算行数
7. sed 替换整个文件夹中所有文件字符
sed -i "s/aa/bb/g" `grep aa -rl file/`
8. 定期删除文件夹的文件,删除前五天的文件
find /home/databacks/2013/ -name "*.sql" -mtime +5 -exec rm {} \;