Hatena::ブログ(Diary)

Rackspace cloud servers Amazon EC2を凌駕(料金・使いやすさ)

2010-02-13

ftpサーバを立てる

ftpサーバを立てる理由

netbeansのリポートプロジェクト機能を使いたいがために、ftpのサーバを立てることになりました。

頭のいい人は、sftpでいいんじゃないと思ったはずです。

しかし、sftpは重いのです。回線の問題なのかめちゃくちゃ遅いです。

固めれば、up,downともに待てるレベルにはなりますが、複数(100以上)のファイルになると3時間以上待つことになります。

ですので、ftpサーバを立てることになったのです。

手順

yum install vsftpd
/etc/init.d/vsftpd start

また、ファイアーフォールを開けてくださいね(ftp)。


このままだと、セキュリティ的にかなり危険です。

ですので、IP制限をかけて特定のIPから以外のアクセスを遮断します。

echo "vsftpd:アクセスするIP" >> /etc/hosts.allow
echo "vsftpd:ALL" >> /etc/hosts.deny

これで、安心のはずです。

明日のログを確認してみます。


参考サイト

オフィシャルサイト

http://cloudservers.rackspacecloud.com/index.php/CentOS_-_Installing_vsftpd


FTPサーバー構築

http://centossrv.com/vsftpd.shtml

2010-01-30

iptablese(ファイアーフォールの設定)

■手順

[root@testMan ~]# system-config-securitylevel-tui

customizeに選択を合わせる(tabを押しながら)

選択状態になったら、spaceキーを押す

そうすると画面が変わる。

Allow incomingをWWWを選択する(spaceキーを押すとチェックがつく)

そして、OKを押してもとの画面に戻って、またOKを押せば完了

メモ:teratermで行った自分は、SELinuxの画面が酷い文字化けを起こしていました。UTF-8にしても、レイアウトが崩れていました。

↓★文字化け対策

http://d.hatena.ne.jp/rackspace/20100121/1264058033


参考サイト

・オフィシャルサイト

http://cloudservers.rackspacecloud.com/index.php/CentOS_5.3_-_Graphical_User_Interface_for_iptables

不正アクセス対策

logwatchから送られるメールを毎日確認することが、最低限のサーバー管理者の責任ですよね。

以前、サーバ管理者としてなんやらと、知らないおじさんにメールで怒られたことがある私は少し気を使って、ログは見てますw


以前のMYサーバーは、sshの22番ポートは閉じていました。

ですので、sshからの不正なアタックは一切ありませんでした。

しかし、ラックスペース(クラウドサーバ)はデフォルトで、22番ポートが空いていたのでそのままにしていました。

ちょこちょこ、不正アクセスもありましたが気にしていませんでした。

しかし、、、

昨日のログ

--------------------- pam_unix Begin ------------------------

sshd:

Authentication Failures:

unknown (ip-174-142-75-230.static.privatedns.com): 19002 Time(s)

root (ip-174-142-75-230.static.privatedns.com): 2995 Time(s)

unknown (66.63.2d.static.xlhost.com): 151 Time(s)

unknown (61.151.246.140): 93 Time(s)

root (66.63.2d.static.xlhost.com): 66 Time(s)

mysql (ip-174-142-75-230.static.privatedns.com): 44 Time(s)

apache (ip-174-142-75-230.static.privatedns.com): 33 Time(s)

news (ip-174-142-75-230.static.privatedns.com): 29 Time(s)

daemon (ip-174-142-75-230.static.privatedns.com): 28 Time(s)

nobody (ip-174-142-75-230.static.privatedns.com): 28 Time(s)

games (ip-174-142-75-230.static.privatedns.com): 27 Time(s)

ftp (ip-174-142-75-230.static.privatedns.com): 26 Time(s)

bin (ip-174-142-75-230.static.privatedns.com): 24 Time(s)

operator (ip-174-142-75-230.static.privatedns.com): 15 Time(s)

root (61.151.246.140): 7 Time(s)

mail (ip-174-142-75-230.static.privatedns.com): 5 Time(s)

mysql (61.151.246.140): 5 Time(s)

svn (61.151.246.140): 5 Time(s)

halt (ip-174-142-75-230.static.privatedns.com): 4 Time(s)

adm (ip-174-142-75-230.static.privatedns.com): 3 Time(s)

gopher (ip-174-142-75-230.static.privatedns.com): 3 Time(s)

mysql (66.63.2d.static.xlhost.com): 3 Time(s)

ftp (66.63.2d.static.xlhost.com): 1 Time(s)

lp (ip-174-142-75-230.static.privatedns.com): 1 Time(s)

mailnull (ip-174-142-75-230.static.privatedns.com): 1 Time(s)

smmsp (ip-174-142-75-230.static.privatedns.com): 1 Time(s)

sync (ip-174-142-75-230.static.privatedns.com): 1 Time(s)

uucp (ip-174-142-75-230.static.privatedns.com): 1 Time(s)

Invalid Users:

Unknown Account: 19246 Time(s)

Bad User: $changeme$: 7 Time(s)

Bad User: !@#$%: 5 Time(s)

Bad User: !@#$%^: 5 Time(s)

Bad User: !@#$%^&: 5 Time(s)

Bad User: !@#$%^&*: 5 Time(s)

Bad User: *: 5 Time(s)

Bad User: @#$%^&: 5 Time(s)

Bad User: : 3 Time(s)

Bad User: ';lkjhgfdsa: 3 Time(s)

Bad User: ][poiuytrewq: 3 Time(s)

Bad User: !7350r13r0: 2 Time(s)

Bad User: !front1er: 2 Time(s)

Bad User: #no641t3mp: 2 Time(s)

Bad User: @d4h0st: 2 Time(s)

Bad User: @dm!n: 2 Time(s)

Bad User: @dm1n: 2 Time(s)

Bad User: @dmin: 2 Time(s)

Bad User: @l!@s: 2 Time(s)

Bad User: @l1@s: 2 Time(s)

Bad User: [fyl.rbyj: 2 Time(s)

Bad User: [jhjijnjrfr: 2 Time(s)

Bad User: `123: 2 Time(s)

Bad User: !hasenfratz: 1 Time(s)

Bad User: !rc: 1 Time(s)

Bad User: !rcd: 1 Time(s)

Bad User: $postgres$: 1 Time(s)

Bad User: -=\-=\=-0: 1 Time(s)

Bad User: @: 1 Time(s)

Bad User: @01: 1 Time(s)

Bad User: @dm1n1str@t0r: 1 Time(s)

Bad User: @m3r1c@: 1 Time(s)

Bad User: @n0nym0us: 1 Time(s)

Bad User: @r0und: 1 Time(s)

Bad User: @thl0n: 1 Time(s)

Bad User: ]': 1 Time(s)

Bad User: `1234567890-=\qwertyuiop[]: 1 Time(s)


19002件の不正アクセスって、ちょっと勘弁してくださいよ。

パスワードは、ハッシュ値を使っているので、割られることはないでしょうが、ちょっと気持ち悪いですね。


ですので、ポート変更をおこないます。

設定変更

sshポート番号22を変更します。

ポート番号は、正直なんでもいいのですがウェルノウン・ポートではなくレジスタードポート番号を使いましょう。

↓一覧

http://fula.jp/blog/index.php?mode=html&cat=port2

sshの設定ファイルの変更

# vi /etc/ssh/sshd_config

#Port 22

Port 好きな番号

# /etc/init.d/sshd restart

ファイアーフォールの設定

sshで使うポートを開けましょう。

http://d.hatena.ne.jp/rackspace/20100130/1264824044


設定後

明日が楽しみです!


結果

まったく不正アクセスがなくなりました。

sshのポートは変更するべきですね!

2010-01-28

redmine高速化

redmineをmongrelで今まで動かしていたのですが、クラウドサーバに移行後、もっと遅くなってしまいまいた。

最初にアクセスする際には、1分ぐらい待たされます。

遅すぎ、遅い、待てない。


そういうことで、mongrelの代わりに、thinを使いました。

thinの方が、軽量で高速のwebサーバのようです。

期待に胸をふくらまして、インストールしました。

手順

gem install thin

thin start

結果

たいして変わりませんでした。

で、ここで終わりにはしたくないので、thinのオプションを調べて、試してみました。

高速起動スクリプト

#!/bin/sh

cd /home/redmine // redmineを置いている場所

thin -e production -u tanii -g tanii -t 86400 -d start

激速になりました☆

もっと、速くなる方法があるか試してみます。


参考サイト

・軽量・高速WebサーバThinを使う手順のメモ(s21g)

http://blog.s21g.com/articles/360

2010-01-26

sendmailがなかなか立ち上がらない

sendmailがなかなか再起動しません。

ログを見てみると下記のようのエラーが発生していました。

My unqualified host name (testMan) unknown; sleeping for retry

名前解決がうまくいっていないようです。

解決策

/etc/hosts

  • 変更前

173.203.197.228 testMan

  • 変更後

173.203.197.228 testMan testMan.localdomain

参考サイト

sendmailがなかなか起動しない

http://search.luky.org/linux-users.9/msg05562.html

2010-01-25

PHP4 互換モード

以前作っていたサイトがphp4(xoops)だったので、php5でphp4互換モードを使って移行してみます。

多分、うまくいかないよね。。

そんときは、諦めます。

以外にうまくいきました。

設定とか何もしないでも、PHP4のソースが普通に動くんですね。

驚きでした。

参考サイト

・PHP4とPHP5の同居方法あれこれ(N.S.WORKs)

http://www.nsworks.com/html/soft_php_inst1_4.html

logwatchの起動・設定

ラックスペースのクラウドサーバで構築した、centosはlogwatch自体は入っていましたが、メールの転送がされていないので、設定していきます。

転送設定

[root@testMan redmine]# vi /etc/aliases

# Person who should get root's mail

#root: marc

root: tanii

[root@testMan redmine]# newaliases

# cd /home/tanii

# vi .forward

転送するメールアドレス

#ll -la|grep .forward

  • rw-r--r-- 1 tanii tanii 21 8月 14 21:42 .forward

毎日、これでログを転送してくれます。

ログは大切ですので、毎日見ましょう。

面白いことがおこっているはずですw

それは、次回説明します。



参考URL

サーバのログ監視ツールを使いこなそう(@IT)

http://www.atmarkit.co.jp/flinux/rensai/root04/root04a.html