| :: Setting up VPN using PPP over SSH :: | |||
| HOME |
The system wide comfiguration file is in /etc/ssh/ssh_config Host * Protocol 2,1 #Ciphers=blowfish-cbc Ciphers=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc #MACS=hmac-sha1 MACS=hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 #Compression=yes #CompressionLevel=8REMEBER THAT YOU SHOULD NOT PUT A PASSPHRASE FOR PROTECTING A PRIVATE SSH KEY. ELSE YOU WILL HAVE TO RUN ssh-agent AND ssh-add FOR PASSWORDLESS LOGIN
mia#>setenv EDITOR pico mia#>visudoThe sudoers file is listed below. More advanced options for sudo can be found here
# sudoers file. # This file MUST be edited with the 'visudo' command as root. # See the sudoers man page for the details on how to write a sudoers file. # Host alias specification # User alias specification # Cmnd alias specification Cmnd_Alias VPN=/usr/sbin/pppd, /bin/kill, /sbin/route # Defaults specification # User privilege specification root ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL # Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL # Samples # %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom # %users localhost=/sbin/shutdown -h now sshvpn ALL=NOPASSWD: VPN
--SNIP--
CLIENT_PPPD_ARGS="noauth noccp novj novjccomp nopcomp noaccomp debug dump logfd 2 passive updetach \
name $vpn_network-client linkname $vpn_network pty"
SERVER_PPPD_ARGS="noauth noccp novj novjccomp nopcomp noaccomp lock"
--SNIP--
A explanation of these arguments can be sought by using man pppd and is provided below:
sent [LCP ConfReq id=0x1 asyncmap 0x0 magic 0xb99a3976] rcvd [LCP ConfReq id=0x1 asyncmap 0x0 magic 0xa7ed8c60] sent [LCP ConfAck id=0x1 asyncmap 0x0 magic 0xa7ed8c60] sent [LCP ConfReq id=0x1 asyncmap 0x0 magic 0xb99a3976] rcvd [LCP ConfAck id=0x1 asyncmap 0x0 magic 0xb99a3976] sent [IPCP ConfReq id=0x1 addr 0.0.0.0] rcvd [IPCP ConfReq id=0x1 addr 192.168.254.201] sent [IPCP ConfAck id=0x1 addr 192.168.254.201] rcvd [IPCP ConfNak id=0x1 addr 192.168.254.200] sent [IPCP ConfReq id=0x2 addr 192.168.254.200] rcvd [IPCP ConfAck id=0x2 addr 192.168.254.200] local IP address 192.168.254.200 remote IP address 192.168.254.201Without these options, pppd on client and server will negotiate compression as see by the following exhange.
Connect: ppp0 <--> /dev/pts/8 rcvd [LCP ConfReq id=0x1 asyncmap 0x0 magic 0x87ecc7a1 pcomp accomp] sent [LCP ConfReq id=0x1 asyncmap 0x0 magic 0xdce8f6b2 pcomp accomp] sent [LCP ConfAck id=0x1 asyncmap 0x0 magic 0x87ecc7a1 pcomp accomp] rcvd [LCP ConfAck id=0x1 asyncmap 0x0 magic 0xdce8f6b2 pcomp accomp] sent [CCP ConfReq id=0x1 deflate 15 deflate(old#) 15] sent [IPCP ConfReq id=0x1 compress VJ 0f 01 addr 0.0.0.0] rcvd [CCP ConfReq id=0x1 deflate 15 deflate(old#) 15] sent [CCP ConfAck id=0x1 deflate 15 deflate(old#) 15] rcvd [IPCP ConfReq id=0x1 compress VJ 0f 01 addr 192.168.254.201] sent [IPCP ConfAck id=0x1 compress VJ 0f 01 addr 192.168.254.201] rcvd [CCP ConfAck id=0x1 deflate 15 deflate(old#) 15] Deflate (15) compression enabled rcvd [IPCP ConfNak id=0x1 addr 192.168.254.200] sent [IPCP ConfReq id=0x2 compress VJ 0f 01 addr 192.168.254.200] rcvd [IPCP ConfAck id=0x2 compress VJ 0f 01 addr 192.168.254.200] local IP address 192.168.254.200 remote IP address 192.168.254.201

sshvpn@mia:~/bin> sh -x ./ppp_over_ssh_vpn start vpn1NOTE: "sh -x" is only used to provide debugging information. Do not use it if you want to script to execute quitely.
sshvpn@mia:~/bin> ifconfig
---SNIP---
ppp0 Link encap:Point-to-Point Protocol
inet addr:192.168.254.253 P-t-P:192.168.254.254 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:66 (66.0 b) TX bytes:72 (72.0 b)
sshvpn@mia:~/bin> netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.254.254 0.0.0.0 255.255.255.255 UH 40 0 0 ppp0*** 131.193.50.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 192.168.1.0 192.168.254.254 255.255.255.0 UG 40 0 0 ppp0*** 192.168.0.0 0.0.0.0 255.255.255.0 U 40 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 40 0 0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 U 40 0 0 lo 0.0.0.0 131.193.50.1 0.0.0.0 UG 40 0 0 eth0 ------------------------------------------------------------------------------ sshvpn@zidler:~> netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.254.253 0.0.0.0 255.255.255.255 UH 40 0 0 ppp0*** 131.193.50.0 0.0.0.0 255.255.255.0 U 40 0 0 eth0 192.168.0.0 192.168.254.253 255.255.255.0 UG 40 0 0 ppp0*** 127.0.0.0 0.0.0.0 255.0.0.0 U 40 0 0 lo 0.0.0.0 131.193.50.1 0.0.0.0 UG 40 0 0 eth0
[sshvpn@mia bin]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT)*** target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT all -- anywhere anywhere LOG all -- anywhere anywhere LOG level warning ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT all -- anywhere anywhere LOG all -- anywhere anywhere LOG level warning Chain OUTPUT (policy ACCEPT) target prot opt source destination
sshvpn@mia:~/bin> sh -x ppp_over_ssh_vpn stop vpn1This will automatically clear related entries in the routing table and stop pppd and the system should return to the initial state.

4-byte packet_length
1-byte padding_length
n1-byte payload;
n2-byte random padding; to make [packet_length + Paddin_length + payload] a multiple of
block_size used by the cipher. (min:= 4 Bytes)
m-byte MAC (message authentication code); e.g. SHA1 (20 Bytes), MD5 (16 Bytes)
---------------------------
Cipher SSH Blk Key
Ver. Sze Sze
---------------------------
3des 1 8 16
blowfish 1 8 32
3des-cbc 2 8 24
blowfish-cbc 2 8 16
cast128-cbc 2 8 16
arcfour 2 8 16
aes128-cbc 2 16 16
aes192-cbc 2 16 24
aes265-cbc 2 16 32
---------------------------
Court: From source code $HOME/temp/openssh-3.5p1/cipher.c
The below table gives an indication of the size of each MAC:
--------------------------- MAC's Size (B) --------------------------- hmac-md5 16 hmac-sha1 20 hmac-ripemd160 20 hmac-sha1-96 6 hmac-md5-96 6 ---------------------------
sshvpn@mia:~/.ssh> cat config Host * Protocol 2,1 #Ciphers=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc Ciphers=blowfish-cbc #MACS=hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 MACS=hmac-sha1 --SNIP--You can also find if your specified Cipher and MAC pair is being used, by using -v option with ssh and looking for the following lines:
sshvpn@mia:~/.ssh> ssh -v sshvpn@zidler OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0x0090701f --SNIP-- debug1: kex: server->client blowfish-cbc hmac-sha1 none debug1: kex: client->server blowfish-cbc hmac-sha1 none --SNIP--
seq_no: 0
Y%*i%|\NU]\Dw-5jOba4Q@D8`?5t#"iBFna^M1OF)t?6++f)m6ZIR:aOY3EvO1Tu!7UhI&0R6O%\uked#BIpvGARZfd+3;
"Olq9Q3J@J5E(,2m,5KVA^}bLse2 4gcVI}C\ccB4*J[VTg(;YIyr.Gg/Z#C]Y)OBs{AXYU}&2Ut6w1+CG kn#zdA?D6H/
U&$lGwG9vgeg]7a+C@R]-\z)]=b=nGLEMQ31dtJ\^K_Wc\b(|Pe+I{N(;3EEtqjC^9nD/:)"|aeZ_)s2n ['i}\8D#.7)k2B\Vl2su4q
This data was generated using
modudpgen, a synonym for Modified UDP generator and
sniffed using ethereal.
--------------------------------------------------------
Application Data Data on wire Overhead
(No comp)
--------------------------------------------------------
100 242 142
275 418 143
350 498 148
502 658 156
613 770 157
750 898 148
849 1010 161
917 1074 157
1010 1170 160
1200 1346 146
--------------------------------------------------------
Average Overhead: 151.8
--------------------------------------------------------
noccp novj novjccomp nopcomp noaccompand at ssh layer by specifying the following in the ~/.ssh/config file.
--SNIP-- Compression=yes CompressionLevel=9 --SNIP--
seq_no: 0
Y%*i%|\NU]\Dw-5jOba4Q@D8`?5t#"iBFna^M1OF)t?6++f)m6ZIR:aOY3EvO1Tu!7UhI&0R6O%\uked#BIpvGARZfd+3;
"Olq9Q3J@J5E(,2m,5KVA^}bLse2 4gcVI}C\ccB4*J[VTg(;YIyr.Gg/Z#C]Y)OBs{AXYU}&2Ut6w1+CG kn#zdA?D6H/
U&$lGwG9vgeg]7a+C@R]-\z)]=b=nGLEMQ31dtJ\^K_Wc\b(|Pe+I{N(;3EEtqjC^9nD/:)"|aeZ_)s2n ['i}\8D#.7)k2B\Vl2su4q
This data was generated using
modudpgen, a synonym for Modified UDP generator and
sniffed using ethereal.
--------------------------------------------------------
Application Data Data on wire Overhead
(full Comp)
--------------------------------------------------------
100 226 126
275 418 143
350 466 116
502 610 108
613 706 93
750 818 68
849 882 33
917 930 13
1010 1026 16
1200 1170 -30
--------------------------------------------------------
Average Overhead: 68.6
--------------------------------------------------------
route add -net network/netmask gw gateway-ipAlthough this method is simple for small networks, it becomes exceedingly difficult to maintain such routes one your network reaches a decent size (> 5 nodes, say). Hence one should avoid using this method, unless you have a very small network.