###### tags: `linux`
# Reverse ssh tunnel
We can use ssh reverse tunnel as an approach to access our local device under the localnet work behind the firewall or NAT.
Please check the detail from [Video tutorial](https://youtu.be/GyHbp6DH-cE)
# Flow diagram

## Cmd
```
ssh -N -R localhost:1234:localhost:22 -i </path/to/ssh/private/key> ubuntu@<cloud.vm.ip.address>
```
## Service file
```
# /etc/systemd/system/<service.name>.service
[Unit]
Description=Setup a secure tunnel to ubuntu pi
After=network.target
[Service]
ExecStart=/usr/bin/ssh -N -R localhost:1234:localhost:22 -i </path/to/ssh/private/key> -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes ubuntu@<cloud.vm.ip.address>
RestartSec=15
Restart=always
[Install]
WantedBy=multi-user.target
```