takafumi blog

日々の勉強メモ

Ubuntu sshインストール

環境   Ubuntu 14.04 LTS

同じVMPlayerですでにNat設定をしていたので、インストールするだけ。
openssh-serverをインストール

$ apt-get install openssh-server

sshd設定

$ cd /etc/ssh
$ vim sshd_config
$ diff -u sshd_config.ORI sshd_config
--- sshd_config.ORI     2014-09-28 19:59:15.491203086 -0700
+++ sshd_config 2014-09-28 22:18:55.158997343 -0700
@@ -25,7 +25,7 @@

 # Authentication:
 LoginGraceTime 120
-PermitRootLogin without-password
+PermitRootLogin no
 StrictModes yes

 RSAAuthentication yes
@@ -49,7 +49,7 @@
 ChallengeResponseAuthentication no

 # Change to no to disable tunnelled clear text passwords
-#PasswordAuthentication yes
+PasswordAuthentication no

 # Kerberos options
 #KerberosAuthentication no

設定内容は

# root(管理者)でのログインを禁止
PermitRootLogin no

# パスワード認証の禁止(鍵方式に変更)
PasswordAuthentication no

#空パスワードの禁止
PermitEmptyPasswords no

そしてhomeディレクトリに公開鍵を設置。パーミッションに注意

$ mkdir -p ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys

これでsshで接続できるようになり、慣れ親しんだCLIに。
後は、apacheとかを入れていけば、webサーバーとして稼動できます。