I try to redirect ssh-traffic from one machine to other with following bash sctipt:
IPTABLES="/usr/sbin/iptables"
$IPTABLES -F
$IPTABLES -X
$IPTABLES -F -t nat
$IPTABLES -X -t nat
$IPTABLES -F -t mangle
$IPTABLES -X -t mangle
$IPTABLES --policy INPUT ACCEPT
$IPTABLES --policy FORWARD ACCEPT
$IPTABLES --policy OUTPUT ACCEPT
$IPTABLES -t nat -A POSTROUTING --out-interface ppp0 -j MASQUERADE
$IPTABLES -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to 192.168.2.2
echo 1 > /proc/sys/net/ipv4/ip_forward
But when I input
ssh user@localhost
or
ssh user@192.168.2.1 # (address of local host)
I get error 'Connection refused'.
Please, help me.