--- title: "Port Forwarding Actions" slug: "port-forwarding-actions" description: "This is a list of actions that can be taken in RapidIdentity Connect to interact with ports and port forwarding." tags: ["RapidIdentity ", "Connect", "Actions", "Port Forwarding"] updated: 2022-06-03T13:20:32Z published: 2022-06-03T13:20:32Z canonical: "help.rapididentity.com/port-forwarding-actions" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.rapididentity.com/llms.txt > Use this file to discover all available pages before exploring further. # Port Forwarding Actions ## Port Forwarding Actions ### closeForwardedLocalPort Close a forwarded a local TCP port. | Property | Value | Description | | --- | --- | --- | | session* | expression, variable | the SSH port forwarding session | | localAddress | text, expression, variable | the bound local source IP address(default: 127.0.0.1, i.e. localhost of RapidIdentity Connect server) | | localPort* | expression, variable | the forwarded local source TCP port | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ### closeForwardedRemotePort Close a forwarded a remote TCP port | Property | Value | Description | | --- | --- | --- | | session* | expression, variable | the SSH port forwarding session | | remotePort* | expression, variable | the forwarded remote source TCP port | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ### forwardLocalPort Forward a TCP port on the RapidIdentity Connect server through a remote CLI connection to a TCP port on a remote server. | Property | Value | Description | | --- | --- | --- | | session* | expression, variable | the SSH port forwarding session | | localAddress | text, expression, variable | the local source IP address (default: 127.0.0.1, i.e. localhost of RapidIdentity Connect server) | | localPort* | expression, variable | the local source TCP port | | remoteAddress | text, expression, variable | the remote destination IP address (default: 127.0.0.1, i.e. localhost of remote CLI server) | | remotePort* | expression, variable | the remote destination TCP port | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ### forwardRemotePort Forward a TCP port from a remote CLI server to a TCP port through the RapidIdentity Connect server. | Property | Value | Description | | --- | --- | --- | | session* | expression, variable | the SSH port forwarding session | | remoteAddress | text, expression, variable | the remote source IP address (default: 127.0.0.1, i.e. localhost of remote CLI server) | | remotePort* | expression, variable | the remote source TCP port | | localAddress | text, expression, variable | the local destination IP address (default: 127.0.0.1, i.e. localhost of RapidIdentity Connect server) | | localPort* | expression, variable | the local destinatin TCP port | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ### openPortForwardingSession Open an SSH port forwarding session. | Property | Value | Description | | --- | --- | --- | | host* | text, expression, variable | the SSH host name or address | | port | expression, variable | the SSH port (default: 22) | | user* | text, expression, variable | the username for the SSH host | | password* | password, string, expression, variable | the password for the SSH host | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ### openPortForwardingSessionWithCert Open an SSH port forwarding session using public/private key authentication. | Property | Value | Description | | --- | --- | --- | | host* | text, expression, variable | the SSH host name or address | | port | expression, variable | the SSH port (default: 22) | | user* | text, expression, variable | the username for the SSH host | | privateKey* | text, expression, variable | the path of the private key file within the project file store or the private key loaded as a byte array | | publicKey | text, expression, variable | the path of the public key file within the project file store or the public key loaded as a byte array | | passPhrase | password, string, expression, variable | the passPhrase for private key (default: none) | | returnVariable | expression, variable | name of the variable to be assigned to the return value | ```actionscript # assumes public and private key have been uploaded to project files store, # and public key has been added as a trusted identity on SSH remote server session = openPortForwardingSessionWithCert("host1.acme.org", 22, "root", "/.ssh/id_rsa", "/.ssh/id_rsa.pub",) ``` ### Complete Example ```actionscript # open SSH session to server inside firewall portForwardSession = openPortForwardingSession("my-ssh-server", "root",) if(portForwardSession) { # forward port 8389 on a loopback address to the ldap server server: port behind firewall portForwarded = forwardLocalPort(portForwardSession, "127.0.0.50", 8389, "my-ldap-server", 389) if (portForwarded) { # connect to the LDAP server through the forwarded port ldapConnection = openLDAPConnection("127.0.0.50", 8389, false, "cn=admin,ou=users,o=system", < Password > ) #... # < do ldap stuff here > #... #close the ldap connection closeLDAPConnection(ldapConnection) # close the forwarded port closeForwardedRemotePort(portForwardSession, 8389) } else { } # close the ssh session close(portForwardSession) } else { } ```