Linux-修改端口,禁止root,限制ip,用户
2015-10-25 15:50
896 查看
1,修改ssh端口 2,禁止root通过ssh远程登录 3,限制用户的SSH访问 4,配置空闲超时退出时间间隔 5,限制只有某一个IP才能远程登录服务器#修改ssh端口
[root@localhost ~]# vi /etc/ssh/sshd_config 在端口#Port 22下面增加Port 2222 [root@localhost ~]# vi /etc/ssh/ssh_config 在端口#Port 22下面增加Port 2222
[root@localhost ~]# service sshd restart#禁止root通过ssh远程登录
[root@localhost ~]# vi /etc/ssh/sshd_config
#找到PermitRootLogin,将后面的yes改为no,把前面的注释#取消,这样root就不能远程登录了 #可以用普通账号登录进去,要用到root的时候使用命令su root 切换到root账户#限制用户的SSH访问
假设我们只要root,userA和userB用户能通过SSH使用系统,向sshd_config配置文件中添加 [root@localhost ~]# vi /etc/ssh/sshd_config AllowUsers root userA userB#配置空闲超时退出时间间隔
用户可以通过ssh登录到服务器,你可以设置一个空闲超时时间间隔。 打开sshd_config配置文件,设置为如下。 [root@localhost ~]# vi /etc/ssh/sshd_config ClientAliveInterval 600 ClientAliveCountMax 0上面的例子设置的空闲超时时间间隔是600秒,即10分钟,
过了这个时间后,空闲用户将被自动踢出出去(可以理解为退出登录/注销)。
#限制只有某一个IP才能远程登录服务器
[root@localhost ~]# vi /etc/hosts.deny #在其中加入sshd:ALL [root@localhost ~]# vi /etc/hosts.allow #在其中进行如下设置: sshd:192.168.1.1 #(只允许192.168.1.1这个IP远程登录服务器)
相关文章推荐
- Linux socket 初步
- 小心服务器内存居高不下的元凶--WebAPI服务
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- 网易云音乐8亿用户背后的伤疤