- export to a remote server port the local port
ssh -R remote_port:localhost:local_port ssh_name
- export to local port a remote server port
ssh -L local_port:remote_server_ip:remote_port ssh_name
- create
/root/scripts/test-support
#!/bin/bash
# export to user1@SERVERNAME port 2000 the local ssh port 22
# using given identity file to connect SERVERNAME:SERVERPORT
ssh -nN \
-o ServerAliveInterval=180 \
-o ServerAliveCountMax=2 \
-R 2000:localhost:22 \
-i ~/.ssh/SOMEIDENTITY.id_rsa \
-p SERVERPORT \
user1@SERVERNAME
- create
/etc/systemd/system/some.service
[Unit]
Description=support test
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=10
User=root
ExecStart=/root/scripts/test-support
[Install]
WantedBy=multi-user.target
- start svc
service some start
-
given a remotehost:port that is accessible from a remote ssh host
-
in order to replicate the same address remotehost:port into local network
-
create tuntap network to hold remotehost ip address
(example: remotehost/net = 10.10.5.2/30 )
ip tuntap add mode tun dev tun0
ip a add 10.10.5.2/30 dev tun0
ip link set dev tun0 up
# test route get
ip r get 10.10.5.2
- connect remotehost:port to local network (tun0)
# -L bindaddress:port:host:hostport
ssh -L 10.10.5.2:5432:10.10.5.2:5432 main-remote