前記事:Ubuntu 14.04 LTS 開発環境構築ログ #02
鍵交換方式でSSH接続するための準備
秘密鍵&公開鍵のペアを作成
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cazborg/.ssh/id_rsa): <Enter>
Created directory '/home/cazborg/.ssh'.
Enter passphrase (empty for no passphrase): <パスフレーズ + Enter>
Enter same passphrase again: <パスフレーズ + Enter>
$
公開鍵の内容を ~/.ssh/authorized_keys
に追加
$ cd ~/.ssh
$ cat id_rsa.pub >> authorized_keys
秘密鍵(~/.ssh/id_rsa)
を作業用PCにSCP
TeraTerm の [ファイル]-[SSH SCP...] でダウンロード。
以後は秘密鍵を使用してSSH接続。
SSHD の設定を変更
root ユーザで SSH 接続できないよう設定を変更し、sshd を再起動
$ sudo cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config.20160309
$ sudoedit /etc/ssh/sshd_config
$ cd /etc/ssh
$ diff -u sshd_config sshd_config.20160309
--- sshd_config 2016-03-09 00:59:48.000000000 +0900
+++ sshd_config.20160309 2014-09-04 17:24:13.000000000 +0900
@@ -25,7 +25,7 @@
# Authentication:
LoginGraceTime 120
-PermitRootLogin no
+PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
$
$ sudo service ssh restart