2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vpsことはじめコマンド集(備忘録)

Last updated at Posted at 2015-02-23
  • あとで体裁ととのえます

作業環境

  • VPS=ConoHa CentOS6.5(64bit)テンプレートイメージ
  • 操作端末=ConoHaシリアルコンソール

1.作業ユーザの作成とsu権限付与

#useradd [作業用ユーザ名]
#passwd [作業用ユーザ名のパスワード]
#usermod -G wheel [作業用ユーザ名]
#visudo

visudo
%wheel ALL=(ALL) ALL
↑行頭の#を削除してコメントアウト解除

2.ホスト名の付与

#hostname [ホスト名]

3.sshログインポリシーの変更

  • ConoHaでは標準でシリアルコンソールが利用でき、sshを使用しなくてもサーバのメンテナンスは実施できるため、ここではsshdを停止しておく。
    ただし、サーバ間でscp転送等を行う時は一時的にservice sshd startで都度起動することで対応することとする。
  • 下記sshd_configではパスワード認証を有効にしているが、通常時sshd自体停止することを前提に利便性優先で設定している。常時sshdを起動させる場合は逆にセキュリティリスクとなるため、公開鍵認証にするなど攻撃に対する対策をした方が良い。

#vi /etc/ssh/sshd_config

/etc/ssh/sshd_config
PermitRootLogin noに変更
PermitPasswordAuthentication yesに変更

#service sshd restart
#service sshd stop

4.日本語環境のインストール

#yum -y groupinstall "Japanese Support"
#vi /etc/sysconfig/i18n

/etc/sysconfig/i18n
en_US → ja_JP に変更

#. /etc/sysconfig/i18n

#ls -l

  • ls -lの実行結果で「合計 0」と表示されればOK。

5.denyhostsのインストール

  • 連続攻撃してきたIPアドレスをブロックしてくれるようになる。

#yum -y install denyhosts
#service denyhosts start
#chkconfig denyhosts on

6.iptablesの設定

  • 最低限のポートだけ開けておく。今後色々なサービスを実装した場合、都度開けることとする。

#vi /etc/sysconfig/iptables

/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

#iptables restart

7.全体のアップデート

  • とりあえずOS全体のパッケージを現在の最新版にしたい時に。
  • 時間がかかります。

# yum update

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?