ubuntu-server-18-04:sshd
文書の過去の版を表示しています。
OpenSSH サーバのインストール
SSHサーバの設定を変更してセキュリティを強化する。
環境
- Ubuntu
- Ubuntu 18.04.3 LTS 64bit
- openssh-server
- 1:7.6p1-4ubuntu0.3
インストールと設定
SSHサーバがインストールされていない場合はインストールする。
$ sudo apt-get install openssh-server
設定ファイルを編集する前にオリジナルの設定ファイルを保存しておく。
/etc/ssh/sshd_config を編集して設定を変える。 <code> $ sudo vi sshd_config
変更点
- Port 5555
- ポートを変更してセキュリティ強化
- PermitRootLogin no
- rootの直接ログインを拒否
- PasswordAuthentication no
- パスワードのみのログインを拒否
- AllowUsers foo
- SSHログインを許可するユーザを限定
$ diff ~/backup/etc/ssh/sshd_config.original /etc/ssh/sshd_config 5a6 > Port 5555 28c29,30 < PermitRootLogin without-password --- > #PermitRootLogin without-password > PermitRootLogin no 52a55 > PasswordAuthentication no 88a92,99 > > > # Added by admin begin > AllowUsers foo > > # Added by admin end > >
ログイン用公開鍵の設置
Puttyやなんかで作った公開鍵(例: hogehoge.pub)をホームディレクトリにコピーし、 SSHの認証用に変換する
$ cd ~/ $ mkdir ./.ssh $ ssh-keygen -i -f ./hogehoge.pub > ./.ssh/authorized_keys
パーミッション変更
$ chmod 700 ./.ssh/ $ chmod 600 ./.ssh/authorized_keys
設定と公開が気の設置が終わったら保存してSSHの設定をリロード
$ sudo service ssh restart
参考
ubuntu-server-18-04/sshd.1566540445.txt.gz · 最終更新: 2019/08/23 15:07 by admin