Remote Access for Linux from your Andriod/iOS

Remote Access for Linux from your Andriod/iOS

Imagine this: you’re lounging at a café, sipping your favorite brew, and suddenly, you remember you need to run a command on your home Linux machine. What if you could whip out your phone and do it right then and there? Buckle up, because we’re about to turn that dream into reality! This guide will walk you through setting up an SSH server, accessing it remotely from your phone, and configuring port forwarding to extend your reach beyond your local network. Let’s get started!

Step 1: Set Up Your SSH Server on Linux

First things first, let’s ensure your Linux machine is ready for remote access.

  1. Install the SSH Server:

    • Open a terminal and run:

        sudo apt-get update
        sudo apt-get install openssh-server
      
    • This installs the OpenSSH server, your gateway to remote access.

  2. Start and Enable the SSH Service:

    • Make sure the SSH service is running and set to start on boot:

        sudo systemctl start ssh
        sudo systemctl enable ssh
      
  3. Verify the SSH Server:

    • Check that SSH is running:

        sudo systemctl status ssh
      

Step 2: Discover Your Linux Machine’s IP Address

To access your machine, you need to know its IP address.

  1. Find Your IP Address:

    • Run:

        ifconfig
      
    • Look for the inet address under your active network interface (e.g., wlp2s0). It might look like 192.168.1.8.

Step 3: Access Your Linux Machine from Your Phone

Now, it’s time for the fun part—connecting to your Linux machine from your phone!

  1. Install an SSH Client on Your Phone:

    • For iOS and Android, Termius is a great choice. Other options include JuiceSSH for Android and Shelly for iOS.

    • Download and install your preferred app from the app store.

  2. Add a New Host in the SSH Client:

    • Open the SSH client app.

    • Add a new host with the following details:

      • Hostname: Your Linux machine’s IP address (e.g., 192.168.1.8).

      • Port: 22 (default for SSH).

      • Username: Your Linux username.

      • Password: Your Linux password (or use key-based authentication).

  3. Connect and Execute Commands:

    • Tap to connect to the host, and voila! You now have your Linux terminal at your fingertips.

Step 4: Extend Your Reach with Port Forwarding

Want to access your Linux machine from anywhere? Port forwarding is your ticket!

  1. Access Your Router’s Web Interface:

    • Find your router’s IP address by running:

        ip route | grep default
      
    • Open a web browser and enter the IP address (e.g., 192.168.1.1). Log in with your router’s credentials.

  2. Navigate to Port Forwarding Settings:

    • The exact path varies by router. Look for terms like “Port Forwarding,” “Virtual Server,” or “NAT.”
  3. Create a Port Forwarding Rule:

    • Add a new rule:

      • Service Name: SSH

      • External Port: 22

      • Internal Port: 22

      • Protocol: TCP

      • Internal IP Address: Your Linux machine’s IP address (e.g., 192.168.1.8)

    • Save and apply the rule.

Conclusion

And there you have it! With SSH and a bit of port forwarding magic, you’re now equipped to access your Linux machine from anywhere in the world. Whether you’re executing commands or transferring files, you can do it all from your phone. So go ahead, embrace the power of remote access, and make the world your playground!