Home » linux相关

VPS常用技巧及方法

3 07月 2010 Views: No Comment Tags:

本文记录一下搭建VPS常用的一些技巧和方法。此文针对基于Ubuntu系统的VPS,不同Linux发行版估计有稍许差异。

修改SSH默认端口

不要使用默认的22端口,这样很容易暴露SSH服务,也为暴力猜解用户名和密码留下了隐患。解决方法,是将/etc/ssh/sshd_config中的Port由默认的22,改为其他端口

不允许root帐号通过SSH直接登录

这样也是相当危险的,一般的做法是通过SSH配置文件,限制root帐号直接登录。修改/etc/ssh/sshd_config,将PermitRootLogin的值改为no。这样,SSH一律使用普通用户登录,在需要执行更高权限命令时,通过sudo命令,或者su成root再执行

限制同一ID同时多重登陆

这样的做法,能让同一个ID,在同一时间内不能被多人同时登录。
实现方法:编辑 /etc/security/limits.conf
加入如下配置项即可:

#<domain>      <type>  <item>         <value>
*                  hard    maxlogins            1

开启只有FTP登录权限,却没有Shell权限的帐户

非常简单,在useradd添加帐户的时候,设置用户的home目录,却不设置shell类型即可

 

useradd -d /home/user1 -s /bin/false user1

这样,为用户设置了home目录,shell为/bin/false,也即一个不存在的shell,这样,这个用户就只有FTP权限,没有Shell权限了。前提是需要在/etc/shells里面加入/bin/false这种不存在的shell类型,这样系统才不会报错。

VPS禁止ping

echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all  #禁止ping

echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all  #允许ping

原创文章如转载,请注明:转载自Xixis Blog [ http://www.xixis.net/ ]
本文链接地址:http://www.xixis.net/archives/vps-techniques-and-methods-used.html

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.