Close
logodocs

SSH Port Forwarding

Port forwarding is enabled for your organization in the Admin UI's security settings. Port forwarding is disabled by default and can only be enabled by users of your organization who have the Account Administrator permission level.

When port forwarding is enabled, strongDM logging is circumvented. Only the user and session timestamp are recorded, not the commands themselves.

How to Enable Port Forwarding

  1. In the Admin UI, go to Settings > Security.
  2. In the Port Forwarding section, under Allow port forwarding through SSH?, select Yes.
  3. Click activate for all servers.

Enabling port forwarding does not turn on port forwarding globally. It simply allows the Allow Port Forwarding checkbox to be shown on SSH Server configuration pages, so port forwarding can be enabled on a per-server basis.

  1. When setting up any given Server, check the Allow Port Forwarding box at the bottom of the Server configuration page. Once enabled, SSH connections proxied by strongDM for this Server will accept local forwarding requests.

Existing connections are not affected by the enabling/disabling of port forwarding. Each connection will only adhere to the current settings at the time it is established.

Local Forwarding Tutorial

With the Allow Port Forwarding option enabled for a server, your sdm executable will accept the same local forwarding (-L) flag that you would normally use with SSH.

In the following example, you will establish a connection and start listening on a forwarded port to send data back and forth. Working through this example requires terminal access and some command-line knowledge.

At this time remote forwarding is not supported.

1. Outline of the command structure:
```bash
sdm ssh [Server Name] -L [Local Port to Forward]:[Target Bind Address]:[Target Port]
```
  1. Identify the name of your server and which port it is running on; save this for the next step.

    local_client:~$ sdm status
    SERVER STATUS PORT TYPE TAGS
    port-forwarding-demo connected 25745 ssh
  2. Establish an SSH connection and forward port 3003 on the client machine to port 4003 on the target server (referred to as localhost in this command because this is internal to the target server). Run the following example on your local terminal. You should see the welcome screen for your remote server if everything was successful.

    local_client:~$ sdm ssh "port-forwarding-demo" -L 3003:localhost:4003

    If port forwarding is disabled, you will still be able to establish a connection; however, attempts to forward ports will fail. Your log messages may reveal error messages similar to channel 3: open failed: administratively prohibited: port forwarding is disabled for this server.

  3. Next, we will use Netcat to listen on port 4003 on the target server. Run the following example on your remote server.

    remote_server:~$ nc -lv 4003
    Listening on [0.0.0.0] (family 0, port 4003)
  4. On your client machine, open up a new terminal window or tab, and connect to your local port 3003 with the following command. You should receive a "connection successful" prompt on the remote server. This shows that the tunnel is working! Try typing hello-from-client, to send text from client to server over the SSH tunnel:

    local_client:~$ nc -v localhost 3003
    Connection to localhost port 3003 [tcp/pxc-splr-ft] succeeded!
    hello-from-client
  5. If all went well, you should have received the messages from your local client on your remote server. At this point, you can also send data back to the client.

    remote_server:~$ nc -lv 4003
    Listening on [0.0.0.0] (family 0, port 4003)
    Connection from [127.0.0.1] port 3003 [tcp/*] accepted (family 2, sport 48742)
    hello-from-client
    greetings from the server

That concludes this brief tutorial on how to use port forwarding with the strongDM executable. This method should work with any applications running on non-privileged ports (ports higher than 1024).

Alternate Syntaxes

Direct with SSH

With this syntax, we will call SSH directly and connect to the port mapped to the server.

local_client:~$ ssh -L 4003:localhost:4003 localhost -p 25745

Alias with SSH

Here we will first create an alias: mapping ssh to sdm. This alias gives us the ability to use the logical name in strongDM rather than the mapped port.

  1. Create alias:

    local_client:~$ alias ssh="/usr/local/bin/sdm ssh wrapped-run"
  2. Connect with the logical name:

    local_client:~$ ssh -L 4003:localhost:4003 "port-forwarding-demo"

If any errors occur, please copy them into an email and send them to support@strongdm.com.

Previous
SSH Certificate Auth
Next
Log Encryption and Storage