Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify RemoteForward in the ssh config file?

I'm trying to setup a an ssh tunnel with remote port forwarding. The idea is the have a VPS act as a means to ssh into remote deployed systems (which currently incorporate a Raspberry Pi). Everything seems to work, but I run into issues when trying to move all arguments into the ~/.ssh/config file. what does work is the setting of the HostName, User, Port and IdentityFile. However setting the RemoteForward parameter does not seem to work.

The following works:

ssh -R 5555:localhost:22 ssh-tunnel

How ever when using the following line in the config file;

Host ssh-tunnel
    ...
    RemoteForward 5555 localhost:22

The following command returns the message "Bad remote forwarding specification 'ssh-tunnel'"

ssh -R ssh-tunnel
like image 658
Kanter van Deurzen Avatar asked Oct 07 '19 13:10

Kanter van Deurzen


People also ask

How do I access SSH config?

The ssh program on a host receives its configuration from either the command line or from configuration files ~/. ssh/config and /etc/ssh/ssh_config . Command-line options take precedence over configuration files. The user-specific configuration file ~/.

What is Sshd_config file?

The sshd_config file is an ASCII text based file where the different configuration options of the SSH server are indicated and configured with keyword/argument pairs. Arguments that contain spaces are to be enclosed in double quotes (").

Is SSH config a text file?

An ssh config file is a text file that contains all of your ssh connection information. This includes the hostname of the server you're connecting to, the username you're using to connect, the port number, and the protocol you want to use.


1 Answers

Obvious I found the answer almost immediately after posting the question. Using the -R flag requires you to set the remote forwarding in the command line call. However because remote forwarding is set in the config file you shouldn't add it to the command. However something confusing occurs in that aside from setting up the tunnel you also ssh into the remote server. To avoid this add the -f and the -N flag. This results in the following command:

ssh -f -N ssh-tunnel
like image 67
Kanter van Deurzen Avatar answered Sep 30 '22 09:09

Kanter van Deurzen