通过SecureCRT访问亚马逊Amazon EC2主机

亚马逊推出了免费的云主机服务器 Amazon EC2,它是通过安全密钥来访问主机的。问题是下载的密钥在SecureCRT 上无法直接使用,需要转换。
下面的方法可以在自己的linux主机上生成securecrt需要的密钥。

首先在 AWS 管理面板中生成密钥对。
将密钥上传到一台自己的linux主机,下面举例文件名为 amazon-ec2-key.pem

修改亚马逊提供的密钥文件权限:
chmod og-r amazon-ec2-key.pem

改写密钥格式为 OpenSSH,如果询问passphrase可以留空(直接回车)
ssh-keygen -p -f amazon-ec2-key.pem

生成公密钥 .pub 文件。使用公密钥时,SecureCRT会询问私密钥或者.pem文件
ssh-keygen -e -f amazon-ec2-key.pem >> amazon-ec2-key.pem.pub

现在可以在 SecureCRT 中使用刚生成的公密钥了,连接到亚马逊的主机也无需再输入密码。

在CentOS上升级PCRE

PCRE – Perl Compatible Regular Expressions

今天在服务器上安装微博,出现错误:

PHP is linked to a version of the PCRE library that does not support Unicode properties. If you are running Red Hat Enterprise Linux / CentOS 5.4 or earlier, see our documentation page on fixing this.

但我的服务器已经是 CentOS 5.5 了

登录服务器检查:

# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

果然PCRE库不支持 unicode 属性。
重新下载了最新版的 PCRE库,运行

./configure –prefix=/usr –enable-utf8 –enable-unicode-properties
make
make install

再次检查系统:

# pcre-config –version
8.10

看起来好像成功了。但是,

# pcretest -C
PCRE version 6.6 06-Feb-2006
Compiled with
UTF-8 support
No Unicode properties support
Newline character is LF
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

怎么还是 6.6 的旧版本?pcre-config 和 pcretest 显示的版本竟然会不一样。

上网Google了很久,才发现问题的根源:

原来在 /lib/ 目录库中还有两个不同的版本

# locate libpcre
> > /lib/libpcre.so.0
> > /lib/libpcre.so.0.0.1
> > /usr/lib/libpcre.a
> > /usr/lib/libpcre.la
> > /usr/lib/libpcre.so
> > /usr/lib/libpcre.so.0

先 unlink /lib/libpcre.so.0
再将 /lib/libpcre.so.0.0.1 改个名字,问题解决

# pcretest -C
PCRE version 8.10 2010-06-25
Compiled with
UTF-8 support
Unicode properties support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack