sshdの設定(Ubuntu)
まずはssh-serverのインストール。
$ sudo apt-get install openssh-server
で、sshdの設定。
内容は
- Rootユーザーでログイン不可
- 空パスワード不可
- パスワード認証不可
- パスワード認証はよろしくないらしい。ので、公開鍵認証のみにしておく。
な感じ。
・ ・ PermitRootLogin no ← 1 ・ ・ PermitEmptyPasswords no ← 2 ・ PasswordAuthentication no ← 3 ・ ・
sshdを再起動。
$ sudo /etc/init.d/ssh restart
鍵の生成(Mac)
MacBookで鍵を生成。
多分、Unixでも同じ・・・だよね?
$ ssh-keygen -t rsa -C "SSH2 RAS key" Generating public/private rsa key pair. Enter file in which to save the key (/***/.ssh/id_rsa): ← key fileのPath。特に変更なし。 Enter passphrase (empty for no passphrase): ← パスフレーズを入力 Enter same passphrase again: ← パスフレーズを再入力 Your identification has been saved in /***/.ssh/id_rsa. Your public key has been saved in /***/.ssh/id_rsa.pub.
.ssh/に作成されたid_rsaファイルが秘密鍵で、id_rsa.pubが公開鍵らしい。
で、公開鍵の方をUbuntu君(sshサーバー側)へコピー。
~/.ssh/authorized_keys
というファイルをUbuntu側で作成し、公開鍵の中身をどうにかしてコピペ。
最後にちゃんと繋がるか確認。
$ ssh [Host名]
参考
http://www.saturn.dti.ne.jp/~jpug/doc/linux/sshd_config.html
http://human.is.kyushu-u.ac.jp/~yosinori/ssh/index-j.html
http://tobysoft.net/wiki/index.php?Ubuntu%2F%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB%B8%E5%A4%CE%C0%DF%C4%EA