リモートで操作できるようにSSHを入れ、設定します。
ssh(Secure SHell)とはネットワークを介してリモート操作をするためのプログラムです。
これを利用する事によって、サーバー機自体にはマウスもモニターもキーボードもつけず、
ただ、電源を入れるだけで他のPCからリモート操作できる為、メンテナンスの利便性が上がります。
これらの通信内容は暗号化され、漏えいを防ぐ事ができるため、一般的なサーバーリモートプログラムとなっています。
しかし、SSHでは完全に遠隔でサーバー機を操れるようになる為、セキュアに構築しないと
「他人に完全に乗っ取られる」ような事や、情報の漏えい、またはBotと化す恐れもあります。
万が一パスワードがクラックされても不正なログインを拒否する事や、そもそもパスワードによる認証を拒否する事も可能ですので
設定についてはしっかりと行う必要があります
SSHのインストール
rootでログインします。apt-get install sshこれでインストールは完了です。
すでに別PCにてリモートログインする準備が整っている場合は
そのままIPアドレスを入力すれば、ログインできるはずです。
これらの設定については「SSHでWindows機からサーバー機をリモート操作する」の項目を参照下さい。
SSHの設定
最低限の設定を行います。SSHの設定ファイルは/etc/ssh/sshd_configです。
vi /etc/ssh/sshd_config青色の文字の部分が変更、追記箇所、赤色が削除です。
/etc/ssh/sshd_config
# Package generated configuration file
# See the sshd(8) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yesPermitRootLogin がデフォルトでは"yes"となっておりますが、"no"に変更します。
これは「rootでのログインを許可するか?」という設定になっています。
SSHへの攻撃として、rootでパスワードの総当たり攻撃が一番多いのですが、
万が一、パスワードが知れてしまっても、この項目をnoとしていればログインされる事はありません。
しかし、もちろん、サーバーの管理者もルートユーザーとしてログインできなくなる為、
管理者がログインする場合はインストール時に作成したユーザー名でログインし、その後、
su -
コマンドよりルートユーザーになるという手順を踏みます。
これらは最低限の設定である為、今後、よりセキュアにしていく関連設定の記事をリンクします。
(追記していきます)
- ログインに鍵認証方式を使用する
- 特定IPからのみ接続を可能にする
- LogWatchでサーバー監視レポート
sshd_configの項目詳細
OpenSSHの日本語マニュアルページにそれぞれの項目の詳細な記述が書かれていいますので、何かあれば一読してみるといいと思います。
- 次の記事→ Logwatchでサーバ監視レポート
- 前の記事→ ページの自動ジャンプ
コメント:0
トラックバック:0
- この記事のトラックバックURL
- http://www.ahref.org/tech/server/ssh-server/77.html/trackback
- この記事へのリンク
- エーエイチレフ linuxサーバー技術情報 からの記事 SSHのインストールと設定















関連記事