This post details on how to use Remmina RDP SSH tunnel with Pre and Post scripts on Debian, with little/no changes this script and the instructions should work on FreeBSD and other GNU/Linux distributions.

Remmina has ‘Pre’ and ‘Post’ command support to execute a script before it connect and after it disconnects, respectively.  We can use these features to workaround certain issues, or any other maintenance. For instance in my case on a Debian 9 XFCE node, Remmina had issues with in built SSH tunnel options, whereas the tunnel was working fine when I create it manually from shell and make Remmina connect to it.

On advice of a Remmina contributor(​antenore) over IRC, I created a very basic shell script that takes arguments to start and stop a tunnel.
I also made changes to my ~/.ssh/config and /etc/hosts files to support this setup, I placed a host entry in /etc/hosts and placed appropriate config to support connecting to ssh tunnel node with single command, like:


# Content of /etc/hosts  : my-tunnel-node

# Content of ~/.ssh/config: 

Host my-tunnel-node
User remoteuser
IdentityFile ~/remote-ssh-key.pem

Now to connect I could use ssh my-tunnel-node and it also removes the overhead of remembering the connection details, with all this set, I then changed Remmina settings.
The RDP connection setting should look like below picture, note the IP address is the remote Windows/RDP node and replace ‘TUNNEL_IP_HERE’ with the actual remote SSH tunnel node, it could be a IP address/FQDN/connect string like user@nodeip.


Below is the content of the script( file, place it under your home directory and update the Remmina settings accordingly.


scriptname="$(basename $0)"

if [ $# -lt 3 ] 
    echo "Usage: $scriptname start | stop  RDP_NODE_IP  SSH_NODE_IP"

case "$1" in


  echo "Starting tunnel to $3"
  ssh -M -S ~/.ssh/$scriptname.control -fnNT -L 3389:$2:3389  $3
  ssh -S ~/.ssh/$scriptname.control -O check $3

  echo "Stopping tunnel to $3"
  ssh -S ~/.ssh/$scriptname.control -O exit $3 


  echo "Did not understand your argument, please use start|stop"



SSH using Control Master: