Software & AppsOperating SystemLinux

How To Connect to Another Computer Using SSH Over the Internet

Ubuntu 21

Secure Shell (SSH) is a protocol that allows secure remote login from one computer to another over an insecure network. It provides strong authentication and encrypted data communications between two computers connecting over an open network infrastructure. This article will guide you through the process of connecting to another computer using SSH over the Internet.

Quick Answer

To connect to another computer using SSH over the Internet, you need to have an SSH client installed on your local computer and an SSH server installed on the remote computer. Once both are set up, you can use the SSH command with the IP address of the remote computer to establish a secure connection.

Prerequisites

Before we start, ensure that you have the following:

  • SSH client installed on your local computer. Most Linux distributions and MacOS come with an SSH client pre-installed. For Windows, you can use a free software like PuTTY.
  • SSH server installed on the remote computer. This can be done by running the command sudo apt-get install openssh-server on the remote computer.

Installing and Starting the SSH Server

First, you need to install the SSH server on the remote computer. This can be done by running the following command:

sudo apt-get install openssh-server

The sudo command allows you to run programs with the security privileges of another user (normally the superuser, or root). apt-get is the package handling utility in Debian-based Linux systems. install is the command to install a package, and openssh-server is the package name.

After installing the SSH server, you need to start it. You can do this by running the following command:

sudo service ssh start

The service command runs a System V init script in as predictable an environment as possible, removing most environment variables. ssh is the service name, and start is the command to start the service.

Checking the Firewall Status

Before you can connect to the remote computer, you need to ensure that there is no firewall blocking the SSH connection. You can do this by running the following command:

sudo ufw status

The ufw command stands for “Uncomplicated Firewall”. It is a user-friendly front-end for managing iptables firewall rules. status is the command to show the status of the firewall.

Finding the IP Address

Next, you need to find the IP address of the remote computer. You can do this by running the following command:

ip addr | grep inet

The ip command is used to show or manipulate routing, devices, policy routing, and tunnels. addr is the command to display the addresses of the network interfaces. grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. inet is the keyword to search for.

Connecting to the Remote Computer

Now that you have the IP address of the remote computer, you can connect to it using SSH. You can do this by running the following command:

ssh -v <username>@<IP address>

The ssh command is used to log into a remote machine and work on the command line. -v is the option for verbose mode. <username> should be replaced with your username on the remote computer, and <IP address> should be replaced with the IP address of the remote computer.

Troubleshooting

If you are unable to connect to the remote computer, there are a few things you can try:

  • Check if the SSH server is running on the remote computer.
  • Check if there is a firewall blocking the SSH connection on your local computer.
  • Use the nmap command to scan for open ports on the remote computer.

By following these steps and troubleshooting any issues that arise, you should be able to connect to another computer through the Internet using SSH. If you need further help, check out the OpenSSH manual or the Ubuntu community help wiki.

Remember, while SSH is a powerful tool for remote administration, it’s important to use it responsibly and ensure that all connections are secure to protect sensitive data. Always use strong, unique passwords and consider additional security measures such as using SSH keys for authentication or changing the default SSH port to reduce the risk of brute-force attacks.

What is SSH?

SSH stands for Secure Shell and is a protocol that allows secure remote login from one computer to another over an insecure network. It provides strong authentication and encrypted data communications between two computers connecting over an open network infrastructure.

How can I install an SSH client on my local computer?

Most Linux distributions and MacOS come with an SSH client pre-installed. For Windows, you can use a free software like PuTTY to install an SSH client.

How do I install an SSH server on a remote computer?

To install an SSH server on a remote computer, you can run the command sudo apt-get install openssh-server on the remote computer if it is running a Debian-based Linux system.

How do I start the SSH server on the remote computer?

After installing the SSH server, you can start it by running the command sudo service ssh start on the remote computer.

How can I check the firewall status on the remote computer?

You can check the firewall status on the remote computer by running the command sudo ufw status.

How can I find the IP address of the remote computer?

To find the IP address of the remote computer, you can run the command ip addr | grep inet on the remote computer.

How do I connect to the remote computer using SSH?

To connect to the remote computer using SSH, you can run the command ssh -v <username>@<IP address> on your local computer, replacing <username> with your username on the remote computer and <IP address> with the IP address of the remote computer.

Leave a Comment

Your email address will not be published. Required fields are marked *