Create an SSH Tunnel to a Node with OpenSSH

If a resource provided by an Oracle Java Cloud Service node uses a port that is not directly accessible through the Internet, you can access that resource by creating a secure shell (SSH) tunnel to the port. You can create an SSH tunnel from a UNIX or UNIX-like platform by using the SSH utility.

In general, an SSH tunnel can map a remote port to any available port number on your local computer. Some protocols, such as Java Remote Method Invocation (RMI), require that the remote and local port numbers be the same value.

  1. Access your service console.
  2. Click the name of the service instance that contains the node that you want to access.
  3. On the Overview page, identify the Public IP address of the node that you want to access.
    For example, 203.0.113.13.
  4. From your computer, run the ssh command to create an SSH tunnel to the node as the opc user.
    Provide the following:
    • The path to the private key that corresponds to the public key that you specified when you created this service instance.

    • The node’s public IP address.

    • The port number on the node to which you want to connect. The SSH tunnel enables connectivity to this remote port by using the port with same number on your local computer.

    The command format is: ssh -i path_to_private_key -L port:node_IP_address:port opc@node_IP_address -N

    For example: ssh -i /home/myuser/id_rsa -L 9001:203.0.113.13:9001 opc@203.0.113.13 -N

  5. If prompted, enter the passphrase for the private key.

Applications that are running on your local computer can now communicate with the node by using localhost:port, where port is the local port number.

After your work with the SSH tunnel is completed, press Ctrl+C to close the SSH tunnel.