opensshをつかった簡易VPN (1) ssh-keygen

192.168.1.38(debian5) と 192.168.1.39(debian5)との間で,
sshを使った簡易のVPNをつくってみる

前提条件として、/etc/hostsあるいはnamedとかで名前解決ができることが
必要。

(1) お互いの証明書の交換

前提として、/etc/ssh/sshd_configの中のPermitRootLoginがyes設定されていることを
確認。(debiancentosはdefaultでOKのはず)

deb505-64-39:~# ssh-keygen       > defaultは sshd v2 rsaの鍵をつくる
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase):  とりあえず空で
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
0f:24:bd:8a:0a:54:34:56:84:3e:a1:xxxxxxxxxxxxxxx root@deb505-64-39
The key's randomart image is:
+--[ RSA 2048]----+
|   ++o           |
|  oo.  .         |
|  +.. . o        |
| ..=   o .       |
| .  =   S        |
|.  . o . o       |
|. o o .   .      |
| o.+             |
|.Eo              |
+-----------------+
deb505-64-39:~# pwd
/root
deb505-64-39:~# cd ./.ssh/
deb505-64-39:~/.ssh# ls -ltr
合計 5
-rw-r--r-- 1 root root 1326 2011-02-25 15:28 known_hosts
-rw-r--r-- 1 root root  399 2011-05-11 21:34 id_rsa.pub
-rw------- 1 root root 1679 2011-05-11 21:34 id_rsa
deb505-64-39:~/.ssh# scp id_rsa.pub 192.168.1.38:/root/.ssh/id_rsa.pub-192.168.1.39
root@192.168.1.38's password: 
id_rsa.pub                                    100%  399     0.4KB/s   00:00    
deb505-64-39:~/.ssh# 
deb505-64-39:~/.ssh# 

192.168.1.38と192.168.1.39との間で同じことをやり、
証明書を互いに送ったのち、cat 証明書 >> /root/.ssh/authorized_keysにコピー

これで、互いにpassword(とpassphrase)無しでsshログインできるようになる。