ユーザ用ツール

サイト用ツール


ubuntu-server-18-04:sshd

差分

このページの2つのバージョン間の差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
ubuntu-server-18-04:sshd [2019/08/23 16:57]
admin
ubuntu-server-18-04:sshd [2020/04/09 20:44] (現在)
admin [ログイン用公開鍵の設置]
行 3: 行 3:
 SSHサーバの設定を変更してセキュリティを強化する。 SSHサーバの設定を変更してセキュリティを強化する。
  
-===== 環境 ===== 
  
-  * Ubuntu +===== インストール環境 ===== 
-    * Ubuntu 18.04.3 LTS 64bit + 
-  * openssh-server +  * Ubuntu 18.04.3 LTS 64bit 
-    * 1:7.6p1-4ubuntu0.3 +  * お名前.com VPS (KVM) 1GB プラン 
 + 
 +^ パッケージ名 ^ バージョン ^ 
 +openssh-server 1:7.6p1-4ubuntu0.3 
 + 
  
 ===== インストールと設定 ===== ===== インストールと設定 =====
行 48: 行 52:
  
 <code> <code>
-$ diff ~/backup/etc/ssh/sshd_config.original /etc/ssh/sshd_config  +$ diff ./sshd_config.original ./sshd_config 
-5a6 +13a14 
-> Port 5555 +> Port 37784 
-28c29,30 +32a34
-< PermitRootLogin without-password +
---- +
-> #PermitRootLogin without-password+
 > PermitRootLogin no > PermitRootLogin no
-52a55+56a59
 > PasswordAuthentication no > PasswordAuthentication no
-88a92,99 +123c126,131 
-+< PasswordAuthentication yes 
 +--- 
 +#PasswordAuthentication yes
  
-> # Added by admin begin 
 > AllowUsers foo > AllowUsers foo
- 
-> # Added by admin end 
- 
  
 </code> </code>
行 82: 行 81:
 鍵長が短くても良い場合は "-b 4096" は不要。 鍵長が短くても良い場合は "-b 4096" は不要。
 <code> <code>
-$ ssh-keygen -t rsa -b 4096 -f ./ssh_key+$ ssh-keygen -t rsa -b 4096 -C "Comment of Key" -f ./ssh_key
 </code> </code>
  
行 90: 行 89:
 </code> </code>
  
- +エクスポートした公開鍵をサーバーのホームディレクトリにコピーして利可能にする
-Puttyやなんかで作った公開鍵(例: hogehoge.pub)をホームディレクトリにコピーし、 +
-SSHの認証用に変換する+
  
 <code> <code>
 $ cd ~/ $ cd ~/
 $ mkdir ./.ssh $ mkdir ./.ssh
-ssh-keygen -i -f ./hogehoge.pub > ./.ssh/authorized_keys+cat ./id_rsa.pub >> ~/.ssh/authorized_keys
 </code> </code>
  
-パーミッション変更+セキュリティのためパーミッション変更しておく。
  
 <code> <code>
行 107: 行 104:
 </code> </code>
  
-設定と公開が気の設置が終わったら保存してSSHの設定リロード+===== ファイアフォールの設定 ===== 
 + 
 +SSH ポートへのアクセス許可する。
  
 <code> <code>
-$ sudo service ssh restart+$ sudo ufw allow 5555/tcp
 </code> </code>
- 
  
 ===== 参考 ===== ===== 参考 =====
ubuntu-server-18-04/sshd.1566547069.txt.gz · 最終更新: 2019/08/23 16:57 by admin