How to Remote Access SSH From Anywhere

Ganesh Velrajan
7 min readOct 19, 2024

--

In this article, we will discuss how to securely remote access your Linux (SSH) server or device from anywhere in the world, making it easier than ever to remotely manage your Linux server.

One of the key features of the Linux server is its ability to be accessed remotely, which allows you to control and manage your Linux server from another machine over the internet.

One common method to remotely access a Linux server is using Secure Shell (SSH), a network protocol that provides a secure way to communicate with a remote device.

Let’s dive in and unlock the full potential of your Linux device with remote access from anywhere via SSH!

Step 1: Set Up Your Linux server for remote SSH access

Before you can remotely access your Linux server, you need to make sure that it is set up correctly.

This includes installing an operating system (such as Ubuntu), connecting it to the internet using an ethernet cable or through Wi-Fi and verify if you can ping ‘www.google.com' from the Linux server.

Once your Linux server is up and running, you are ready to proceed with remote access.

Step 2: Enable SSH on Your Linux server

By default, SSH is disabled on a Linux server for security reasons. However, you can easily enable it using the following steps:

  1. Open a terminal window on your Linux server.
  2. Run systemctl status sshd and check if the OpenSSH server is already running.
  3. If not, run systemctl start sshd
  4. Recheck the status of the sshd server by running systemctl status sshd again.

If SSH server(sshd) is not installed in your Linux machine, install the OpenSSH server and client on your Linux server first.

Step 3: Set up Linux server Remote Access software

Remote access to the SSH server running in your Linux server requires installing and running a secure remote access software (a VPN like software) on the Linux server.

Once the remote access software is installed on the Linux server, the Linux server device can be securely accessed from anywhere in the world without setting up port forwarding on your router.

SocketXP, a popular Linux server remote access and IoT Device Management platform, enables you to easily manage, control, monitor and remote access a fleet of Linux server from a web portal.

How SocketXP Linux server Remote Access solution works

  1. First, you need to install the SocketXP agent on your Linux server.
  2. The agent will securely connect (using an SSL/TLS tunnel) to the SocketXP IoT Cloud Gateway using an authentication token.
  3. You can then SSH connect to your Linux server from the SocketXP Web Portal or using your own SSH client such as PuTTY.

Follow the steps below to install and setup SocketXP agent on your Linux server.

Step 3.1: Download and Install

Follow the download and install instructions to install the SocketXP agent on your Linux server device.

Step 3.2: Get your Authentication Token

Sign up at https://portal.socketxp.com and get your authentication token.

Use the following command to login to the SocketXP IoT Cloud Gateway using the auth token.

$ socketxp login [your-auth-token-goes-here]

Step 3.3: Connect the device to the SocketXP Cloud Gateway

Use the following command to connect the Linux server to the cloud gateway using a secure SSL/TLS connection.

$ socketxp connect tcp://localhost:22 

Connected to SocketXP Cloud Gateway.
Access the device securely using the SocketXP agent in IoT Slave Mode.

For the security of your device, SocketXP IoT Solution doesn’t create any public TCP endpoints that can be connected by any SSH client from the internet.

SocketXP private tunnel endpoints are not exposed to the internet and can be accessed only using the SocketXP agent (in IoT slave mode using the auth token of the user) or through the web terminal in the SocketXP web portal as shown below.

Single-Touch Installation Command

The 3 step instruction explained above to setup SocketXP on your Linux server is a tedious process, if you have thousands of Linux server devices to install, configure and manage.

With this in mind, SocketXP IoT Remote Access Solution also provides a single-touch installation command for installing and configuring SocketXP IoT Agent on large number Linux server devices.

Copy and paste the below single-touch installation command from the SocketXP Portal page on to the terminal of your Linux server. The command shown below will download a shell script that will install, configure, setup SocketXP IoT agent on your Linux server. After the command completes, the Linux server device would show up as online in the SocketXP Portal page.

Step 4: Remotely Accessing the Linux server SSH from anywhere

Your Linux server is now ready to be accessed remotely from anywhere in the world using SSH by simply logging in to the SocketXP Web Portal.

Click the “Devices” tab, find your IoT device listed in the table. Click the terminal icon next to your device. It will take you to a SSH login screen.

You have two options to perform SSH authenticate and login:

  1. SSH public private keys
  2. SSH Username and Password

Select SSH key authentication, provide the login user name and click login. A short-lived SSH key pair will be synced between the SSH web client and your device. Once the login is successful, the SSH key will be deleted from the device.

After a successful SSH key based login, you’ll also be shown a shell prompt to enter any Linux command.

The above screen capture shows the “htop” command output from an SSH session created using the SSH web terminal window in the SocketXP web portal.

SocketXP also provides the option of using your own SSH client software such as PuTTY, SecureCRT, OpenSSH client etc. We will discuss this option below in the next section on SocketXP Slave Mode agent feature.

Step 4.1: Configuring SocketXP agent to run in slave mode

This is an alternate method for connecting to your Linux SSH server from anywhere using the SocketXP solution.

If you don’t want to access your Linux server SSH from the browser and you want to access it using your own SSH client such as PuTTY then follow the instructions below.

This method is also extremely useful if you want to setup and use SSH public private keys to remote access your Linux server.

First download and install the SocketXP agent software on your accessing device (such as a laptop running Windows or Mac OS).

Next, configure the agent to run in slave mode (or local proxy mode) using the command option “-iot-slave” as shown in the example below.

$ socketxp connect tcp://localhost:3000 --iot-slave --peer-device-id "2233-4455-abcd-34445" --peer-device-port 22 --authtoken <auth token> 

Connected.
Access the TCP service using SocketXP agent in IoT Slave Mode or from the web portal.

You shall find the device ID of your Linux server from the SocketXP Portal page in the IoT Devices section.

Now you can access your Linux server’s SSH server using the above SocketXP local endpoint, as shown below.

You can use your own SSH client such as PuTTY to connect to your remote Linux server SSH shell. The following example uses a command line based SSH client tool.

You can create your own SSH public private keys using the ssh-keygen tool.

$ ssh -i ~/.ssh/john-private.key john@localhost -p 3000

Advantages of using SocketXP for Linux server remote SSH access from anywhere:

SocketXP uses secure reverse proxy SSL/TLS tunnels to connect to your Linux server over the internet, so that your device is not directly exposed to the internet. Also, the data transmitted is encrypted using SSL/TLS.

SSH uses the same cryptography technology used by banks and governments to exchange highly confidential data over the internet.

The data transferred gets encrypted end-to-end between the SSH client and the SSH server.

SocketXP has no way to decrypt or eavesdrop your encrypted data without knowing your SSH private keys. SocketXP merely acts as an SSL/TLS reverse proxy server for your encrypted data traffic transmitted through the SSH connection.

Conclusion

Remotely connecting to your Linux server via SSH provides a convenient and powerful way to control your Linux server from anywhere in the world.

By following the steps outlined in this article, you can easily enable SSH, install SocketXP Linux server Remote Access agent on it, and connect to it remotely using SSH from anywhere.

Once connected, you can perform various tasks to manage your Linux server remotely, including updating packages, installing/removing software, configuring settings, transferring files, managing processes, and performing system maintenance.

With remote access, you can unlock the full potential of your Linux server and use it for a wide range of applications with ease and convenience.

--

--

Ganesh Velrajan
Ganesh Velrajan

Written by Ganesh Velrajan

Ganesh Velrajan is the founder of Ampas Labs Inc. Learn more about our SSH Remote Access Solutions at https://www.socketxp.com and https://www.bastionxp.com

No responses yet