04 Oct 2012 ssh tunnel Configuration Centaurus ##################################### ### ### Setup ssh tunnel between Centaurus and Vangas. ### Initiated by Centaurus, useful for tunneling from Vangas back to Centaurus. ### ### ### Create tunnel user, "mole", and ### configure for ssh key login. ### # Create user "mole" on Vangas. # user mole already exists on Vangas. # as root on Centaurus ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. 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. ls -al drwx------ 2 root root 4096 Oct 5 06:08 .ssh cd .ssh mv id_rsa.pub id_rsa.centaurus.pub # Vangas is behind router Fantail scp id_rsa.centaurus.pub toby@fantail:/tmp toby@vangas:~$ sudo chown mole:martech /tmp/id_rsa.centaurus.pub # as mole on Vangas mole@vangas:~$ cd .ssh mole@vangas:~/.ssh$ mv /tmp/id_rsa.centaurus.pub . mole@vangas:~/.ssh$ ls -l -rw------- 1 mole martech 786 2012-08-30 13:15 authorized_keys -rw-r--r-- 1 mole martech 396 2012-10-04 23:23 id_rsa.centaurus.pub -rw-r--r-- 1 mole martech 393 2012-08-30 13:15 id_rsa.mizuki.pub -rw-r--r-- 1 mole martech 393 2012-01-27 12:53 id_rsa.naruto.pub mole@vangas:~/.ssh$ cat id_rsa.centaurus.pub >> authorized_keys # as root on Centaurus root@centaurus:~/.ssh# ssh mole@fantail.coas.oregonstate.edu mole@vangas:~$ # straight in, no problems ##################################### ### ### Setup tunnel script and ### root@centaurus:~# vi /usr/local/sbin/tunnel_to_vangas set REMOTE_PORT="6622" root@centaurus:~# /usr/local/sbin/tunnel_to_vangas # as toby on Vangas toby@vangas:~$ ssh -p 6622 localhost toby@localhost's password: xxxxx toby@centaurus:~$ # Working. toby@centaurus:~$ ps aux | grep mole root 21645 0.0 0.2 5348 2540 ? S 06:30 0:00 ssh -nNT -C -p 22 -R 6622:localhost:22 mole@fantail