LoginSignup
0
0

More than 5 years have passed since last update.

CentOS 7.4 on Microsoft Azureでsshd_configを設定

Posted at

はじめに

私は、勉強がてら気軽にLinuxに触れられる環境が欲しくて、Microsoft Azureを契約しています。
Linux環境を構築する際、いつも最初に行うsshd_configの設定だけど、毎度記憶が曖昧になるので、備忘録としてメモしたいと思います。

Linux環境

今回、sshd_configの設定を行ったLinux環境は以下の通りです。

  • CentOS 7.4
  • Microsoft Azure上の仮想マシンとして構築

Microsoft AzureでLinux環境を構築すると、最初から22番ポートに対してSSHでアクセスできますので、putty等でSSHアクセスして下さい。

sshd_configの設定

下記設定ファイルを開きます。

# vi /etc/ssh/sshd_config

[PermitRootLogin]

rootでのログインを許可するか否かの設定。
セキュリティ観点から許可しないようにします。

設定前:#PermitRootLogin yes
設定後:PermitRootLogin no

[PubkeyAuthentication]

公開鍵認証を許可するか否かの設定。
今となっては、パスワード認証よりこちらが普通。

設定前:#PubkeyAuthentication yes
設定後:PubkeyAuthentication yes

[PasswordAuthentication]

パスワード認証を許可するか否かの設定。
前述の通り、SSH公開鍵認証を使用するので、無効化します。

設定前:PasswordAuthentication no
設定後:PasswordAuthentication no

※Microsoft Azureで仮想マシン作成時、SSH公開鍵認証を選択して既に鍵を設定済みなので、本設定は既に無効化済みでした。OSから自分で構築する方は設定値を確認して下さい。

[PermitEmptyPasswords]

空パスワードを許可するか否かの設定。
当然、許可しないです。

設定前:#PermitEmptyPasswords no
設定後:PermitEmptyPasswords no

[ChallengeResponseAuthentication]

チャレンジレスポンス認証を許可するか否かの設定。
チャレンジレスポンス認証は、パスワードとランダムな数値列(チャレンジ)を合成した認証方式で、結局パスワードを使用するので、無効化した方が良いです。

設定前:ChallengeResponseAuthentication no
設定後:ChallengeResponseAuthentication no

※Microsoft Azureで仮想マシン作成時、SSH公開鍵認証を選択して既に鍵を設定済みなので、本設定は既に無効化済みでした。OSから自分で構築する方は設定値を確認して下さい。


設定はここまでです。
編集内容を保存し、sshdサービスを再起動して、設定内容を反映して下さい。

# systemctl restart sshd.service

お疲れ様でした。

0
0
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
0
0