-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh_tunnel
More file actions
17 lines (9 loc) · 843 Bytes
/
ssh_tunnel
File metadata and controls
17 lines (9 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ssh -f [email protected] -L 2000:personal-server.com:25 -N
The -f tells ssh to go into the background just before it executes the command.
This is followed by the username and server you are logging into.
The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port.
Finally the -N instructs OpenSSH to not execute a command on the remote system.
example:
- for tunneling the remote mysql server to the local port 9000
ssh -L 9000:localhost:3306 [email protected] -nNT &
You might have noticed that every time we create a tunnel you also SSH into the server and get a shell. This isn’t usually necessary, as you’re just trying to create a tunnel. To avoid this we can run SSH with the -nNT flags, such as the following, which will cause SSH to not allocate a tty and only do the port forwarding.