SSH |
host1# ssh -L 9999:localhost:5432 host2
host1# psql -h localhost -p 9999 -U postgres
AllowTcpForwarding yes
host1# ssh -L 9999:host3:5432 host2
ssh -L 0.0.0.0:9999:host3:5432 host2
ssh -R 9999:localhost:5432 host1
host1# ssh host2
host2# ssh host3
host3# ssh host4
host4# echo hello host4
host1# ssh -L 9991:localhost:9992 host2
host2# ssh -L 9992:localhost:9993 host3
host3# ssh -L 9993:localhost:5432 host4
host1# ssh -L 2222:localhost:2222 host2
host2# ssh -L 2222:host4:22 host3
host1# ssh -p 2222 localhost
host4# echo hello host4
# host4
host1# scp -P 2222 /local/path/to/some/file localhost:/path/on/host4
# host4
host1# scp -P 2222 localhost:/path/on/host4 /local/path/to/some/file
# TCP forwarding host4
host1# ssh -p 2222 -L 9999:localhost:5432 localhost
host1# psql -h localhost -p 9999 -U postgres
# , ssh -p ,
# scp -P
PermitTunnel yes
PermitTunnel point-to-point
PermitRootLogin without-password
sudo service sshd restart # centos
/etc/init.d/ssh restart # (debian/ubuntu)
host1# sudo ssh -w 5:5 root@host2
host1# ifconfig tun5
tun5 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
POINTOPOINT NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
host1# sudo ifconfig tun5 192.168.150.101/24 pointopoint 192.168.150.102
host2# sudo ifconfig tun5 192.168.150.102/24 pointopoint 192.168.150.101
host1# #
host1# sudo iptables-save > /tmp/iptables.rules.orig
host1# sudo iptables -I INPUT 1 -i tun5 -j ACCEPT
host2# #
host2# sudo iptables-save > /tmp/iptables.rules.orig
host2# sudo iptables -I INPUT 1 -i tun5 -j ACCEPT
host1# ping 192.168.150.102
host2# ping 192.168.150.101
host1# psql -h 192.168.150.102 -U postgres
host2# # IP forwarding
host2# sudo sysctl -w net.ipv4.ip_forward=1
host2# # IP forwarding host1
host2# sudo iptables -I FORWARD 1 -s 192.168.150.101 -j ACCEPT
host2# # IP forwarding host1
host2# sudo iptables -I FORWARD 1 -d 192.168.150.101 -j ACCEPT
host2# # IP host1
host2# sudo iptables -t nat -A POSTROUTING -s 192.168.150.101 -j MASQUERADE
host1# # , host2 192.168.2.x, host1
host1# # host2 192.168.2.x
host1# sudo ip route add 192.168.2.0/24 via 192.168.150.2
host1# # host1
host1# ping 192.168.2.1
host1# sudo iptables-restore < /tmp/iptables.rules.orig
host2# sudo iptables-restore < /tmp/iptables.rules.orig
host1# ssh -L 2222:localhost:2222 host2
host2# ssh -L 2222:host4:22 host3
host1# sudo ssh -p 2222 -w 5:5 root@localhost
host1# # host4 : sudo ssh -w 5:5 root@host4
host1# sudo ifconfig tun5 192.168.150.101/24 pointopoint 192.168.150.102
host4# sudo ifconfig tun5 192.168.150.102/24 pointopoint 192.168.150.101
host4# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.150.0 0.0.0.0 255.255.255.0 U 0 0 0 tun5
192.168.56.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
0.0.0.0 192.168.56.254 0.0.0.0 UG 0 0 0 eth0
host4# route -n > routes.orig
host1# # IP forwarding
host1# sudo sysctl -w net.ipv4.ip_forward=1
host1# #
host1# sudo iptables-save > /tmp/iptables.rules.orig
host1# # IP forwarding host4
host1# sudo iptables -I FORWARD 1 -s 192.168.150.102 -j ACCEPT
host1# # IP forwarding host4
host1# sudo iptables -I FORWARD 1 -d 192.168.150.102 -j ACCEPT
host1# # IP host4
host1# sudo iptables -t nat -A POSTROUTING -s 192.168.150.102 -j MASQUERADE
host4# sudo ip route replace default via 192.168.150.101
host4# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.150.0 0.0.0.0 255.255.255.0 U 0 0 0 tun5
192.168.56.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
0.0.0.0 192.168.150.101 0.0.0.0 UG 0 0 0 tun5
host4# ping 8.8.8.8
nameserver 8.8.8.8
nameserver 8.8.4.4
host4# ping ya.ru
host1# # host1
host1# sudo iptables-restore < /tmp/iptables.rules.orig
host1# # net.ipv4.ip_forward
host2# # - host4:
host2# sudo ip route replace default via 192.168.56.254
host2# # DNS- /etc/resolv.conf
client1# ssh-keygen -t rsa
ssh-copy-id user@sshserver
ssh user@sshserver
PasswordAuthentication no
PubkeyAuthentication yes
GSSAPIAuthentication no
UseDNS no
service sshd restart>
/etc/init.d/ssh restart
7) ()
help.ubuntu.com/community/SSH_VPN
habrahabr.ru/post/87197
blog.backslasher.net/ssh-openvpn-tunneling.html