<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>VPS侦探 &#187; 安全</title>
	<atom:link href="http://www.vpser.net/tag/%e5%ae%89%e5%85%a8/feed" rel="self" type="application/rss+xml" />
	<link>http://www.vpser.net</link>
	<description>致力于VPS主机推荐、VPS管理维护、VPS优惠信息及VPS相关的信息共享平台</description>
	<lastBuildDate>Mon, 06 Feb 2012 01:24:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>lnmp去掉nginx上传目录的PHP执行权限</title>
		<link>http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html</link>
		<comments>http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html#comments</comments>
		<pubDate>Sun, 12 Jun 2011 01:04:27 +0000</pubDate>
		<dc:creator>VPSer</dc:creator>
				<category><![CDATA[VPS安全]]></category>
		<category><![CDATA[LNMP]]></category>
		<category><![CDATA[LNMP一键安装包]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP执行权限]]></category>
		<category><![CDATA[一键安装包]]></category>
		<category><![CDATA[上传目录]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[目录]]></category>

		<guid isPermaLink="false">http://www.vpser.net/?p=2336</guid>
		<description><![CDATA[LNMP有一个缺点就是目录权限设置上不如Apache，有时候网站程序存在上传漏洞或类似pathinfo的漏洞从而导致被上传了php木马，而给网站和服务器带来比较大危险。建议将网站目录的PHP权限去掉，当访问上传目录下的php文件时就会返回403错误。下面VPS侦探详细介绍如何把lnmp环境下去掉指定目录的PHP执行权限。 首先要编辑nginx的虚拟主机配置，在fastcgi的location语句的前面按下面的内容添加： 1、单个目录去掉PHP执行权限 location ~ /attachments/.*\.(php&#124;php5)?$ { deny all; } 将attachments目录的PHP执行权限去掉。 2、多个目录去掉PHP执行权限 location ~ /(attachments&#124;upload)/.*\.(php&#124;php5)?$ { deny all; } 将attachments、upload这二个目录的PHP执行权限去掉。 附上一个完整的虚拟主机的例子供参考： server { listen 80; server_name bbs.vpser.net; index index.html index.htm index.php; root /home/wwwroot/bbs.vpser.net;&#160; include discuz.conf; location ~ /(attachments&#124;upload)/.*\.(php&#124;php5)?$ { deny all; } location ~ .*\.(php&#124;php5)?$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } access_log off; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lnmp.org" target="_blank"><img class="alignnone size-full wp-image-1730" title="lnmp" src="http://www.vpser.net/uploads/2010/11/lnmp.gif" alt="" width="156" height="46" /></a></p>
<p><a href="http://lnmp.org" target="_blank">LNMP</a>有一个缺点就是目录权限设置上不如Apache，有时候网站程序存在上传漏洞或类似<a href="http://www.vpser.net/manage/nginx-securit-script_filename.html" target="_blank">pathinfo的漏洞</a>从而导致被上传了php木马，而给网站和服务器带来比较大危险。建议将网站目录的PHP权限去掉，当访问上传目录下的php文件时就会返回403错误。下面<a href="http://www.vpser.net" target="_blank">VPS侦探</a>详细介绍如何把<a href="http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html" target="_blank">lnmp环境下去掉指定目录的PHP执行权限</a>。</p>
<p>首先要编辑nginx的虚拟主机配置，在fastcgi的location语句的前面按下面的内容添加：</p>
<p>1、单个目录去掉PHP执行权限<span id="more-2336"></span></p>
<div style="background-color: #ffffff; border: #00a0c6 1px dashed; width: auto; margin-bottom: 10px;">location ~ /attachments/.*\.(php|php5)?$ {<br />
deny all;<br />
}</div>
<p>将attachments目录的PHP执行权限去掉。</p>
<p>2、多个目录去掉PHP执行权限</p>
<div style="background-color: #ffffff; border: #00a0c6 1px dashed; width: auto; margin-bottom: 10px;">location ~ /(attachments|upload)/.*\.(php|php5)?$ {<br />
deny all;<br />
}</div>
<p>将attachments、upload这二个目录的PHP执行权限去掉。</p>
<p>附上一个完整的虚拟主机的例子供参考：</p>
<div style="background-color: #ffffff; border: #00a0c6 1px dashed; width: auto; margin-bottom: 10px;">server<br />
{<br />
listen       80;<br />
server_name bbs.vpser.net;<br />
index index.html index.htm index.php;<br />
root  /home/wwwroot/bbs.vpser.net;&nbsp;</p>
<p>include discuz.conf;<br />
location ~ /(attachments|upload)/.*\.(php|php5)?$ {<br />
deny all;<br />
}<br />
location ~ .*\.(php|php5)?$<br />
{<br />
fastcgi_pass  unix:/tmp/php-cgi.sock;<br />
fastcgi_index index.php;<br />
include fcgi.conf;<br />
}</p>
<p>access_log  off;<br />
}</p>
</div>
<p>如有问题欢迎在本文下方留言或到<a href="http://bbs.vpser.net/" target="_blank">VPS论坛</a>交流反馈。</p>
<p>原创文章，谢绝转载！</p>
<h2  class="related_post_title">相关文章：</h2><ul class="related_post"><li><a href="http://www.vpser.net/build/lnmp-0-4.html" title="LNMP一键安装包 0.4发布">LNMP一键安装包 0.4发布</a></li><li><a href="http://www.vpser.net/build/lnmp-0-8.html" title="LNMP一键安装包 0.8发布">LNMP一键安装包 0.8发布</a></li><li><a href="http://www.vpser.net/build/lnmp-auto-upgrade-nginx-to-any-version.html" title="LNMP一键安装包 自动无缝升级Nginx至任意版本">LNMP一键安装包 自动无缝升级Nginx至任意版本</a></li><li><a href="http://www.vpser.net/build/lnmp-0-6.html" title="LNMP一键安装包 0.6 正式发布">LNMP一键安装包 0.6 正式发布</a></li><li><a href="http://www.vpser.net/build/lnmp-0-5.html" title="LNMP一键安装包 0.5 正式发布">LNMP一键安装包 0.5 正式发布</a></li><li><a href="http://www.vpser.net/manage/lnmp-lnmpa-imagemagick-install-tutorial.html" title="LNMP/LNMPA一键安装包ImageMagick安装配置教程">LNMP/LNMPA一键安装包ImageMagick安装配置教程</a></li><li><a href="http://www.vpser.net/security/lnmp-php-pathinfo.html" title="请各位lnmp用户检查php pathinfo设置！重要！">请各位lnmp用户检查php pathinfo设置！重要！</a></li><li><a href="http://www.vpser.net/build/lnmp-0-7-lnmpa.html" title="LNMP一键安装包 0.7发布 &#8211; 支持LNMPA">LNMP一键安装包 0.7发布 &#8211; 支持LNMPA</a></li><li><a href="http://www.vpser.net/manage/lnmp-upgrade-php-script.html" title="LNMP一键安装包 PHP自动升级脚本">LNMP一键安装包 PHP自动升级脚本</a></li><li><a href="http://www.vpser.net/build/lnmp-faq.html" title="LNMP一键安装包常见问题错误及解决方法(不定期更新)">LNMP一键安装包常见问题错误及解决方法(不定期更新)</a></li></ul><hr />
<p><small>© VPSer for <a href="http://www.vpser.net">VPS侦探</a>, 2011. |
<a href="http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html">Permalink</a> |
<a href="http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html#comments">9 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html&title=lnmp去掉nginx上传目录的PHP执行权限">del.icio.us</a>
<br/>
Post tags: <a href="http://www.vpser.net/tag/lnmp" rel="tag">LNMP</a>, <a href="http://www.vpser.net/tag/lnmp%e4%b8%80%e9%94%ae%e5%ae%89%e8%a3%85%e5%8c%85" rel="tag">LNMP一键安装包</a>, <a href="http://www.vpser.net/tag/nginx" rel="tag">Nginx</a>, <a href="http://www.vpser.net/tag/php%e6%89%a7%e8%a1%8c%e6%9d%83%e9%99%90" rel="tag">PHP执行权限</a>, <a href="http://www.vpser.net/tag/%e4%b8%80%e9%94%ae%e5%ae%89%e8%a3%85%e5%8c%85" rel="tag">一键安装包</a>, <a href="http://www.vpser.net/tag/%e4%b8%8a%e4%bc%a0%e7%9b%ae%e5%bd%95" rel="tag">上传目录</a>, <a href="http://www.vpser.net/tag/%e5%ae%89%e5%85%a8" rel="tag">安全</a>, <a href="http://www.vpser.net/tag/%e7%9b%ae%e5%bd%95" rel="tag">目录</a><br/>
<br/>
<img src="http://www.vpser.net/images/tuijian.gif"> <a href="http://www.vpser.net/usa-vps/">美国VPS推荐</a>  | <a href="http://shop63846532.taobao.com/">军哥代购 - 提供美国及海外VPS/VPN/域名代购，美元/欧元代付</a> QQ：503228080
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>SSH密钥登录让Linux VPS/服务器更安全</title>
		<link>http://www.vpser.net/security/linux-ssh-authorized-keys-login.html</link>
		<comments>http://www.vpser.net/security/linux-ssh-authorized-keys-login.html#comments</comments>
		<pubDate>Mon, 10 Jan 2011 01:25:43 +0000</pubDate>
		<dc:creator>VPSer</dc:creator>
				<category><![CDATA[VPS安全]]></category>
		<category><![CDATA[Linux VPS]]></category>
		<category><![CDATA[Putty]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[xshell]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[密钥登录]]></category>
		<category><![CDATA[服务器]]></category>

		<guid isPermaLink="false">http://www.vpser.net/?p=1857</guid>
		<description><![CDATA[随着PHP越来越流行，Linux VPS/服务器的使用也越来越多，Linux的安全问题也需要日渐加强，如果你安装过DenyHosts并设置过邮件提醒，你每天可能会受到数封DenyHosts Report将前来破解SSH密码的IP加入/etc/hosts.deny。 Linux SSH登录有两种： 1、使用密码验证登录 通常VPS或服务器开通后都是直接提供IP和root密码，使用这种方式就是通过密码方式登录。如果密码不够强壮，而且没有安装DenyHosts之类的防止SSH密码破解的软件，那么系统安全将存在很大的隐患。 2、使用密钥验证登录 基于密钥的安全验证必须为用户自己创建一对密钥，并把共有的密钥放在需要访问的服务器上。当需要连接到SSH服务器上时，客户端软件就会向服务器发出请求，请求使用客户端的密钥进行安全验证。服务器收到请求之后，先在该用户的根目录下寻找共有密钥，然后把它和发送过来的公有密钥进行比较。如果两个密钥一致，服务器就用公有的密钥加密“质询”，并把它发送给客户端软件（putty,xshell等）。客户端收到质询之后，就可以用本地的私人密钥解密再把它发送给服务器，这种方式是相当安全的。 一、生成密钥 因为puttygen生成的密钥有问题可能会出现：“Server refused our key”，最好使用XShell生成密钥或者在远程Linux VPS/服务器生成密钥。 1、在Linux远程服务器生成密钥： 登录远程Linux  VPS/服务器，执行： root@vpser:~# ssh-keygen -t rsa //先运行这个命令 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):                   //直接回车 Created directory '/root/.ssh'. Enter passphrase (empty for no [...]]]></description>
			<content:encoded><![CDATA[<p>随着PHP越来越流行，Linux VPS/服务器的使用也越来越多，Linux的安全问题也需要日渐加强，如果你安装过<a href="http://www.vpser.net/security/denyhosts.html" target="_blank">DenyHosts</a>并设置过邮件提醒，你每天可能会受到数封<a href="http://www.vpser.net/security/denyhosts.html" target="_blank">DenyHosts</a> Report将前来破解SSH密码的IP加入/etc/hosts.deny。</p>
<p>Linux SSH登录有两种：</p>
<p><strong>1、使用密码验证登录</strong></p>
<p>通常VPS或服务器开通后都是直接提供IP和root密码，使用这种方式就是通过密码方式登录。如果密码不够强壮，而且没有安装<a href="http://www.vpser.net/security/denyhosts.html" target="_blank">DenyHosts</a>之类的<a href="http://www.vpser.net/security/denyhosts.html" target="_blank">防止SSH密码破解的软件</a>，那么系统安全将存在很大的隐患。</p>
<p><strong>2、使用密钥验证登录<span id="more-1857"></span><br />
</strong></p>
<p>基于密钥的安全验证必须为用户自己创建一对密钥，并把共有的密钥放在需要访问的服务器上。当需要连接到SSH服务器上时，客户端软件就会向服务器发出请求，请求使用客户端的密钥进行安全验证。服务器收到请求之后，先在该用户的根目录下寻找共有密钥，然后把它和发送过来的公有密钥进行比较。如果两个密钥一致，服务器就用公有的密钥加密“质询”，并把它发送给客户端软件（<a href="http://www.vpser.net/other/putty-ssh-linux-vps.html" target="_blank">putty</a>,xshell等）。客户端收到质询之后，就可以用本地的私人密钥解密再把它发送给服务器，这种方式是相当安全的。</p>
<h2>一、生成密钥</h2>
<p>因为puttygen生成的密钥有问题可能会出现：“<span style="font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif, 新宋体, 宋体; line-height: 18px; color: #333333;">Server refused our key”，最好使用XShell生成密钥或者在远程Linux VPS/服务器生成密钥。</span></p>
<h3><span style="font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif, 新宋体, 宋体; line-height: 18px; color: #333333;">1、在Linux远程服务器生成密钥：</span></h3>
<div><span style="font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif, 新宋体, 宋体; line-height: 18px; color: #333333;">登录远程Linux  VPS/服务器，执行：</span></div>
<div><span style="font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif, 新宋体, 宋体; line-height: 18px; color: #333333;"> </span>root@vpser:~# <strong>ssh-keygen -t rsa</strong> //先运行这个命令</div>
<div id="_mcePaste">Generating public/private rsa key pair.</div>
<div id="_mcePaste">Enter file in which to save the key (/root/.ssh/id_rsa):                   //直接回车</div>
<div id="_mcePaste">Created directory '/root/.ssh'.</div>
<div id="_mcePaste">Enter passphrase (empty for no passphrase):                                    //输入密钥密码</div>
<div id="_mcePaste">Enter same passphrase again:                                                                 //重复密钥密码</div>
<div id="_mcePaste">Your identification has been saved in /root/.ssh/id_rsa.         //提示公钥和私钥已经存放在/root/.ssh/目录下</div>
<div id="_mcePaste">Your public key has been saved in /root/.ssh/id_rsa.pub.</div>
<div id="_mcePaste">The key fingerprint is:</div>
<div id="_mcePaste">15:23:a1:41:90:10:05:29:4c:d6:c0:11:61:13:23:dd root@vpser.net</div>
<div id="_mcePaste">The key's randomart image is:</div>
<div id="_mcePaste">+--[ RSA 2048]----+</div>
<div id="_mcePaste">|=&amp;@Bo+o o.o      |</div>
<div id="_mcePaste">|=o=.E  o . o     |</div>
<div id="_mcePaste">| .    .   .      |</div>
<div id="_mcePaste">|         .       |</div>
<div id="_mcePaste">|        S        |</div>
<div id="_mcePaste">|                 |</div>
<div id="_mcePaste">|                 |</div>
<div id="_mcePaste">|                 |</div>
<div id="_mcePaste">|                 |</div>
<div id="_mcePaste">+-----------------+</div>
<div id="_mcePaste">root@vpser:~#</div>
<div id="_mcePaste">将/root/.ssh/下面的id_rsa和id_rsd.pub妥善保存。</div>
<h3>2、使用XShell生成密钥</h3>
<p>Xshell是一款Windows下面功能强大的SSH客户端，能够按分类保存N多会话、支持Tab、支持多密钥管理等等，管理比较多的VPS/服务器使用XShell算是比较方便的，推荐使用。</p>
<p><a href="http://soft.vpser.net/manage/xshell/xsh040074b.exe" target="_blank">下载XShell</a>，安装，运行XShell，点击菜单：Tool -&gt;User Key Generation Wizard，出现如下提示：</p>
<p><a href="http://www.vpser.net/security/linux-ssh-authorized-keys-login.html" target="_blank"><img class="alignnone size-full wp-image-1878" title="XShell生成密钥" src="http://www.vpser.net/uploads/2011/01/xshell-key-generation-wizard-1.jpg" alt="" width="464" height="372" /></a></p>
<p><img class="alignnone size-full wp-image-1879" title="XShell生成密钥2" src="http://www.vpser.net/uploads/2011/01/xshell-key-generation-wizard-2.jpg" alt="" width="465" height="368" /></p>
<p><img class="alignnone size-full wp-image-1880" title="XShell生成密钥3" src="http://www.vpser.net/uploads/2011/01/xshell-key-generation-wizard-3.jpg" alt="" width="467" height="371" /></p>
<p><img class="alignnone size-full wp-image-1881" title="XShell生成密钥4" src="http://www.vpser.net/uploads/2011/01/xshell-key-generation-wizard-4.jpg" alt="" width="470" height="370" /></p>
<p>点击Save as file将密钥保存为id_rsa.pub。</p>
<h2>二、将密钥添加到远程Linux服务器</h2>
<p>1、用<a href="http://www.vpser.net/manage/winscp.html" target="_blank">winscp</a>，将id_rsa.pub文件上传到<span style="font-family: Simsun; line-height: normal; font-size: small;">/root/.ssh/下面（</span><span style="font-family: Simsun; line-height: normal; font-size: small;">如果没有则创建此目录）</span><span style="font-family: Simsun; line-height: normal; font-size: small;">，并重命名为：</span><span style="font-family: Simsun; line-height: normal; font-size: small;">authorized_keys</span><span style="font-family: Simsun; line-height: normal; font-size: small;">（如果是在Linux服务器上生成的密钥直接执行：<strong>mv /root/.ssh/id_rsa.pub </strong></span><span style="font-family: Simsun; line-height: normal; font-size: small;"><strong>/root/.ssh/authorized_keys</strong></span><span style="font-family: Simsun; line-height: normal; font-size: small;">），再执行：<strong>chmod 600 /root/.ssh/authorized_keys</strong> 修改权限。</span></p>
<p><span style="font-family: Simsun; font-size: x-small;"><span style="line-height: normal;"><span style="font-family: Simsun; line-height: normal; font-size: small;"> </span></span></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">2、</span><span style="font-family: Simsun; line-height: normal; font-size: small;">修改</span>/etc/ssh/sshd_config 文件，将RSAAuthentication 和 PubkeyAuthentication 后面的值都改成yes ，保存。</p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">3、</span><span style="font-family: Simsun; line-height: normal; font-size: small;">重启sshd服务，</span><span style="font-family: Simsun; line-height: normal; font-size: small;">Debian/Ubuntu执行</span><span style="font-family: Simsun; line-height: normal; font-size: small;"><strong>/etc/init.d/ssh restart</strong> ；CentOS执行：</span><span style="font-family: arial, sans-serif; line-height: 20px; font-size: x-small;"><strong><span style="font-family: Simsun; line-height: normal; font-size: small;">/etc/init.d/</span>sshd restart</strong></span><span style="font-family: Simsun; line-height: normal; font-size: small;">。</span></p>
<h2>三、客户端测试使用密钥登录</h2>
<h3><span style="font-family: Simsun; line-height: normal; font-size: small;">1、使用putty登录</span></h3>
<p><span style="font-family: Simsun; font-size: x-small;"><span style="line-height: normal;">putty使用的私钥文件和Linux服务器或XShell的私钥格式不同，如果使用</span></span><span style="font-family: Simsun; line-height: normal; font-size: small;">putty</span><span style="font-family: Simsun; font-size: x-small;"><span style="line-height: normal;">的话，需要将Linux主机上生成的</span></span>id_rsa文件下载的本地。运行<a href="http://soft.vpser.net/manage/putty/puttyfile_0.60cn.zip" target="_blank">putty压缩包</a>里面的puttygen.exe，选择Conversions-&gt;Import key选择私钥文件id_rsa，输入密钥文件的密码，会出现如下界面：</p>
<p><img class="alignnone size-full wp-image-1882" title="putty-export-ppk" src="http://www.vpser.net/uploads/2011/01/putty-export-ppk.jpg" alt="" width="481" height="460" /></p>
<p>点击“Save Private Key”，将私钥保存为id_rsa.ppk</p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">运行putty，在Host Name填写：root@主机名或ip</span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><a href="http://www.vpser.net/security/linux-ssh-authorized-keys-login.html" target="_blank"><img class="alignnone size-full wp-image-1863" title="putty密钥登录" src="http://www.vpser.net/uploads/2011/01/putty-1.jpg" alt="" width="454" height="431" /></a></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><img class="alignnone size-full wp-image-1864" title="putty密钥登录" src="http://www.vpser.net/uploads/2011/01/putty-2.jpg" alt="" width="452" height="432" /></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><a href="http://www.vpser.net/security/linux-ssh-authorized-keys-login.html" target="_blank"><img class="alignnone size-full wp-image-1865" title="putty-3" src="http://www.vpser.net/uploads/2011/01/putty-3.jpg" alt="" width="431" height="107" /></a></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">如果设置了密钥密码，出现：Passphrase for key "imported-openssh-key"时输入密钥密码。</span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">如果设置没问题就会登录成功，出现用户提示符。</span></p>
<h3><span style="font-family: Simsun; line-height: normal; font-size: small;">2、XShell登录</span></h3>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">运行XShell，选择菜单File-&gt;New，按如下提示填写：</span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><img class="alignnone size-full wp-image-1883" title="xshell-new-session-1" src="http://www.vpser.net/uploads/2011/01/xshell-new-session-1.jpg" alt="" width="598" height="477" /></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><img class="alignnone size-full wp-image-1884" title="xshell-new-session-2" src="http://www.vpser.net/uploads/2011/01/xshell-new-session-2.jpg" alt="" width="516" height="456" /></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">打开创建好的Session</span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><img class="alignnone size-full wp-image-1885" title="xshell-select-session" src="http://www.vpser.net/uploads/2011/01/xshell-select-session.jpg" alt="" width="281" height="235" /></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;"><img class="alignnone size-full wp-image-1886" title="xshell-key-login" src="http://www.vpser.net/uploads/2011/01/xshell-key-login.jpg" alt="" width="595" height="477" /></span></p>
<p><span style="font-family: Simsun; line-height: normal; font-size: small;">如果设置没问题就会登录成功，出现用户提示符。</span></p>
<h3><span style="font-family: Simsun; line-height: normal; font-size: small;">3、Linux客户端登录测试</span></h3>
<p><span style="font-family: Simsun; font-size: x-small;"><span style="line-height: normal;">在Linux客户端执行：<strong>chmod 600 /root/id_rsa</strong> 再执行：<strong>ssh root@www.vpser.net -i /root/id_rsa</strong> /root/id_rsa为私钥文件，<span style="font-family: Simsun; line-height: normal; font-size: small;">第一次链接可能会提示确认，输入yes即可，再按提示输入密钥密码，没有问题就会出现用户提示符。</span></span></span></p>
<h2>四、修改远程Linux服务器sshd服务配置</h2>
<h3><span style="font-family: Simsun; line-height: normal; font-size: small;">1、修改</span>/etc/ssh/sshd_config 文件</h3>
<p>将PasswordAuthentication yes 修改成 PasswordAuthentication no</p>
<h3>2、重启sshd服务</h3>
<p>Debian/Ubuntu执行/etc/init.d/ssh restart ；CentOS执行：/etc/init.d/sshd restart。</p>
<p>ok，设置完成。</p>
<p>再提醒一下一定要保存好Putty私钥文件id_rsa.ppk或Linux服务器下载下来的id_rsa私钥文件。</p>
<p>原创文章，谢绝转载！</p>
<h2  class="related_post_title">相关文章：</h2><ul class="related_post"><li><a href="http://www.vpser.net/other/putty-ssh-linux-vps.html" title="如何使用Putty远程(SSH)管理Linux VPS">如何使用Putty远程(SSH)管理Linux VPS</a></li><li><a href="http://www.vpser.net/coupons/burstnet-2011-december-yearend20-coupons.html" title="BurstNet 2011年12月年末Windows和Linux VPS 8折优惠码">BurstNet 2011年12月年末Windows和Linux VPS 8折优惠码</a></li><li><a href="http://www.vpser.net/coupons/vpsyou-2011-december-coupons.html" title="VPSYOU 2011年12月Xen Linux VPS 7折优惠码">VPSYOU 2011年12月Xen Linux VPS 7折优惠码</a></li><li><a href="http://www.vpser.net/coupons/vpszz-openvz-linux-vps-coupon.html" title="VPSZZ &#8211; OpenVZ Linux VPS优惠码">VPSZZ &#8211; OpenVZ Linux VPS优惠码</a></li><li><a href="http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html" title="lnmp去掉nginx上传目录的PHP执行权限">lnmp去掉nginx上传目录的PHP执行权限</a></li><li><a href="http://www.vpser.net/manage/screen.html" title="SSH远程会话管理工具 &#8211; screen使用教程">SSH远程会话管理工具 &#8211; screen使用教程</a></li><li><a href="http://www.vpser.net/coupons/vpsyou-2010-october-coupons.html" title="VPSYOU 2010年10月VPS+虚拟主机优惠码">VPSYOU 2010年10月VPS+虚拟主机优惠码</a></li><li><a href="http://www.vpser.net/usa-vps/vpsyou-openvz-vps.html" title="VPSYOU OpenVZ Linux VPS 正式上线，3$起售">VPSYOU OpenVZ Linux VPS 正式上线，3$起售</a></li><li><a href="http://www.vpser.net/manage/scp.html" title="Linux SSH远程文件/目录传输命令scp">Linux SSH远程文件/目录传输命令scp</a></li><li><a href="http://www.vpser.net/other/linux-vps-ram.html" title="Linux VPS内存占用那么多？- 解析Linux内存机制">Linux VPS内存占用那么多？- 解析Linux内存机制</a></li></ul><hr />
<p><small>© VPSer for <a href="http://www.vpser.net">VPS侦探</a>, 2011. |
<a href="http://www.vpser.net/security/linux-ssh-authorized-keys-login.html">Permalink</a> |
<a href="http://www.vpser.net/security/linux-ssh-authorized-keys-login.html#comments">13 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.vpser.net/security/linux-ssh-authorized-keys-login.html&title=SSH密钥登录让Linux VPS/服务器更安全">del.icio.us</a>
<br/>
Post tags: <a href="http://www.vpser.net/tag/linux-vps" rel="tag">Linux VPS</a>, <a href="http://www.vpser.net/tag/putty" rel="tag">Putty</a>, <a href="http://www.vpser.net/tag/ssh" rel="tag">SSH</a>, <a href="http://www.vpser.net/tag/xshell" rel="tag">xshell</a>, <a href="http://www.vpser.net/tag/%e5%ae%89%e5%85%a8" rel="tag">安全</a>, <a href="http://www.vpser.net/tag/%e5%af%86%e9%92%a5%e7%99%bb%e5%bd%95" rel="tag">密钥登录</a>, <a href="http://www.vpser.net/tag/%e6%9c%8d%e5%8a%a1%e5%99%a8" rel="tag">服务器</a><br/>
<br/>
<img src="http://www.vpser.net/images/tuijian.gif"> <a href="http://www.vpser.net/usa-vps/">美国VPS推荐</a>  | <a href="http://shop63846532.taobao.com/">军哥代购 - 提供美国及海外VPS/VPN/域名代购，美元/欧元代付</a> QQ：503228080
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.vpser.net/security/linux-ssh-authorized-keys-login.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Linux VPS上查找后门程序</title>
		<link>http://www.vpser.net/security/linux-vps-find-backdoor.html</link>
		<comments>http://www.vpser.net/security/linux-vps-find-backdoor.html#comments</comments>
		<pubDate>Sat, 06 Feb 2010 01:07:31 +0000</pubDate>
		<dc:creator>VPSer</dc:creator>
				<category><![CDATA[VPS安全]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[后门]]></category>
		<category><![CDATA[安全]]></category>

		<guid isPermaLink="false">http://www.vpser.net/?p=907</guid>
		<description><![CDATA[在初中和高中时对网络安全这方面很感兴趣，接触过的网络安全知识也都是些Windows下的，Linux下的接触比较少，但是很多VPSer们也想更多的了解Linux下面的安全设置，所以先在网上找些给大家恶补一下，我有时间也多恶补一下，多写些教程。 每个进程都会有一个PID，而每一个PID都会在/proc目录下有一个相应的目录，这是Linux（当前内核2.6）系统的实现。 一般后门程序，在ps等进程查看工具里找不到，因为这些常用工具甚至系统库基本上已经被动过手脚（网上流传着大量的rootkit。假如是内核级的木马，那么该方法就无效了）。 因为修改系统内核相对复杂（假如内核被修改过，或者是内核级的木马，就更难发现了），所以在/proc下，基本上还都可以找到木马的痕迹。 思路： 在/proc中存在的进程ID，在 ps 中查看不到（被隐藏），必有问题。 for i in /proc/[0-9]* ; do 讨论： 检查系统(Linux)是不是被黑，其复杂程度主要取决于入侵者“扫尾工作”是否做得充足。对于一次做足功课的入侵来说，要想剔除干净，将是一件分精密、痛苦的事情，通常这种情况，需要用专业的第三方的工具（有开源的，比如tripwire，比如aide）来做这件事情。 而专业的工具，部署、使用相对比较麻烦，也并非所有的管理员都能熟练使用。 实际上Linux系统本身已经提供了一套“校验”机制，在检查系统上的程序没有被修改。比如rpm包管理系统提供的 -V 功能： rpm -Va 即可校验系统上所有的包，输出与安装时被修改过的文件及相关信息。但是rpm系统也可能被破坏了，比如被修改过。 转载自：http://www.bsdmap.com/2010/02/02/proc-usage/ 相关文章：BurstNet 2011年6月Windows和Linux VPS优惠码Linux VPS上自动备份文件并发送到Gmail (适用G级数据的备份)(转)Linux VPS上安装KDE, Gnome和VNC为什么在美国Windows VPS要比Linux VPS贵好多？CentOS Linux VPS Kloxo/Lxadmin虚拟主机控制面板安装教程Linux VPS延长SSH连接时间设置Linux VPS流量查看/监测工具 &#8212; vnStatLinux VPS上DenyHosts阻止SSH暴力攻击Linux VPS使用Xen-Shell重装系统Linux VPS禁止某个IP访问 © VPSer for VPS侦探, 2010. &#124; Permalink &#124; One comment &#124; Add [...]]]></description>
			<content:encoded><![CDATA[<p>在初中和高中时对网络安全这方面很感兴趣，接触过的网络安全知识也都是些Windows下的，Linux下的接触比较少，但是很多VPSer们也想更多的了解Linux下面的安全设置，所以先在网上找些给大家恶补一下，我有时间也多恶补一下，多写些教程。</p>
<p>每个进程都会有一个PID，而每一个PID都会在/proc目录下有一个相应的目录，这是Linux（当前内核2.6）系统的实现。</p>
<p>一般后门程序，在ps等进程查看工具里找不到，因为这些常用工具甚至系统库基本上已经被动过手脚（网上流传着大量的rootkit。假如是内核级的木马，那么该方法就无效了）。</p>
<p>因为修改系统内核相对复杂（假如内核被修改过，或者是内核级的木马，就更难发现了），所以在/proc下，基本上还都可以找到木马的痕迹。</p>
<p>思路：<br />
在/proc中存在的进程ID，在 ps 中查看不到（被隐藏），必有问题。</p>
<p>for i in /proc/[0-9]* ; do<span id="more-907"></span></p>
<p>讨论：</p>
<p>检查系统(Linux)是不是被黑，其复杂程度主要取决于入侵者“扫尾工作”是否做得充足。对于一次做足功课的入侵来说，要想剔除干净，将是一件分精密、痛苦的事情，通常这种情况，需要用专业的第三方的工具（有开源的，比如<a href="http://sourceforge.net/projects/tripwire/" target="_blank">tripwire</a>，比如<a title="Advanced Intrusion Detection Environment" href="http://sourceforge.net/projects/aide/" target="_blank">aide</a>）来做这件事情。</p>
<p>而专业的工具，部署、使用相对比较麻烦，也并非所有的管理员都能熟练使用。</p>
<p>实际上Linux系统本身已经提供了一套“校验”机制，在检查系统上的程序没有被修改。比如rpm包管理系统提供的 -V 功能：</p>
<p>rpm -Va</p>
<p>即可校验系统上所有的包，输出与安装时被修改过的文件及相关信息。但是rpm系统也可能被破坏了，比如被修改过。</p>
<p>转载自：<a href="http://www.bsdmap.com/2010/02/02/proc-usage/">http://www.bsdmap.com/2010/02/02/proc-usage/</a></p>
<h2  class="related_post_title">相关文章：</h2><ul class="related_post"><li><a href="http://www.vpser.net/coupons/burstnet-2011-june-windows-linux-vps-coupons.html" title="BurstNet 2011年6月Windows和Linux VPS优惠码">BurstNet 2011年6月Windows和Linux VPS优惠码</a></li><li><a href="http://www.vpser.net/security/vps-auto-bakup-send-by-gmail.html" title="Linux VPS上自动备份文件并发送到Gmail (适用G级数据的备份)(转)">Linux VPS上自动备份文件并发送到Gmail (适用G级数据的备份)(转)</a></li><li><a href="http://www.vpser.net/manage/linux-vps-install-kde-gnome-vnc.html" title="Linux VPS上安装KDE, Gnome和VNC">Linux VPS上安装KDE, Gnome和VNC</a></li><li><a href="http://www.vpser.net/usa-vps/windows-vps-linux-vps.html" title="为什么在美国Windows VPS要比Linux VPS贵好多？">为什么在美国Windows VPS要比Linux VPS贵好多？</a></li><li><a href="http://www.vpser.net/vps-cp/centos-linux-vps-kloxol-xadmin.html" title="CentOS Linux VPS Kloxo/Lxadmin虚拟主机控制面板安装教程">CentOS Linux VPS Kloxo/Lxadmin虚拟主机控制面板安装教程</a></li><li><a href="http://www.vpser.net/manage/linux-vps-ssh-clientalivecountmax.html" title="Linux VPS延长SSH连接时间设置">Linux VPS延长SSH连接时间设置</a></li><li><a href="http://www.vpser.net/manage/vnstat.html" title="Linux VPS流量查看/监测工具 &#8212; vnStat">Linux VPS流量查看/监测工具 &#8212; vnStat</a></li><li><a href="http://www.vpser.net/security/denyhosts.html" title="Linux VPS上DenyHosts阻止SSH暴力攻击">Linux VPS上DenyHosts阻止SSH暴力攻击</a></li><li><a href="http://www.vpser.net/vps-cp/linux-vps-xen-shell-rebuild.html" title="Linux VPS使用Xen-Shell重装系统">Linux VPS使用Xen-Shell重装系统</a></li><li><a href="http://www.vpser.net/security/linux-vps-deny-ip.html" title="Linux VPS禁止某个IP访问">Linux VPS禁止某个IP访问</a></li></ul><hr />
<p><small>© VPSer for <a href="http://www.vpser.net">VPS侦探</a>, 2010. |
<a href="http://www.vpser.net/security/linux-vps-find-backdoor.html">Permalink</a> |
<a href="http://www.vpser.net/security/linux-vps-find-backdoor.html#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.vpser.net/security/linux-vps-find-backdoor.html&title=Linux VPS上查找后门程序">del.icio.us</a>
<br/>
Post tags: <a href="http://www.vpser.net/tag/linux" rel="tag">Linux</a>, <a href="http://www.vpser.net/tag/vps" rel="tag">VPS</a>, <a href="http://www.vpser.net/tag/%e5%90%8e%e9%97%a8" rel="tag">后门</a>, <a href="http://www.vpser.net/tag/%e5%ae%89%e5%85%a8" rel="tag">安全</a><br/>
<br/>
<img src="http://www.vpser.net/images/tuijian.gif"> <a href="http://www.vpser.net/usa-vps/">美国VPS推荐</a>  | <a href="http://shop63846532.taobao.com/">军哥代购 - 提供美国及海外VPS/VPN/域名代购，美元/欧元代付</a> QQ：503228080
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.vpser.net/security/linux-vps-find-backdoor.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

