Long ago, being able to access equipment remotely became essential. Today, we can hardly picture life without remote computer control. Depending on the operating system you are using, there are numerous ways How to use SSH to Connect to a Remote Server in Linux or Windows? however, the two most used protocols are:
- SSH (Secure Shell) for Linux-based computers
- RDP is the Remote Desktop Protocol for Windows-based computers.
The client and server programs are used by the two protocols to create a remote connection. With the help of these tools, you may connect to and control other computers remotely, transfer data and perform almost any other task that can be completed while physically in front of the computer.
There are a few prerequisites to fulfill before you can establish secure remote desktop communication with a distant machine:
- The remote computer must always be on and connected to the internet.
- Installation and activation of the client and server programs are required.
- The name or IP address of the remote computer you want to connect to is required.
- To access the remote computer, you must have the required permissions.
- The remote connection must be permitted by the firewall settings.
What is SSH?
With the help of a text-based interface and the Secure Shell protocol, also known as Secure Socket Shell, you can safely connect to a server or remote computer.
A shell session will be launched once a secure SSH connection has been made, allowing you to issue commands from the client software on your local computer to control the server.
The most common users of this protocol are system and network administrators, as well as anyone who needs to remotely administer a computer in a very secure way.
How Does SSH Function?
A client and the associated server-side component are required to establish an SSH connection. Installing an SSH client on your computer will enable you to connect to a server or another machine. If the credentials are validated, the client establishes the encrypted connection using the specified remote host information.
An SSH daemon is a server-side component that continuously monitors a particular TCP/IP port for potential client connection requests. The SSH daemon will respond with the software and protocol versions it supports once a client begins a connection, and the two will then share their identity information.
If the credentials entered are accurate, SSH starts a fresh session for the proper environment. Version 2 of the SSH protocol is the standard for communication between SSH servers and SSH clients.
How to Enable an SSH Connection?
You must ensure that the client and server components are set up on the local and remote machines, respectively, in order to establish an SSH connection. OpenSSH is a popular SSH program that is open source and used with Linux distributions. OpenSSH may be easily installed.
How to use SSH to Connect to a Remote Server in Linux or Windows? Both the machine you use for connecting and the server’s terminal must be accessible. Keep in mind that Ubuntu does not come pre-installed with an SSH server.
Installing the OpenSSH Client
Make sure an SSH client is not already installed before continuing with the installation. An SSH client is already included in many Linux distributions. To connect to a server on a Windows system, install Putty or another client of your choice.
You must: in order to determine whether the client is accessible on your Linux-based machine:
1: Open an SSH window. You may either type “terminal” into your search engine or hit CTRL + ALT + T on your keyboard.
2: In the terminal, enter after typing ssh.
3: If the client is set up, you will get a response that appears as follows:
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
[user@] hostname [command]
This indicates that you are prepared to establish a virtual or real machine connected remotely. You must set up the OpenSSH client otherwise.
To install the OpenSSH client on your PC, use the following command:
- install OpenSSH-client with sudo apt-get
- When prompted, enter your superusers password.
- To complete the installation, press Enter.
If you have the required access rights and know the hostname or IP address of any machine that has the server-side program on it, you can now SSH into that machine.
How to Install an OpenSSH Server?
A system has to have the server-side component of the SSH software toolkit in order to accept SSH connections.
Try connecting to the local host if you first want to see if the remote computer’s Ubuntu setup has an OpenSSH server that can accept SSH connections:
1: Launch the server machine’s terminal. You may either type “terminal” into your search engine or hit CTRL + ALT + T on your keyboard.
2: SSH localhost, then press Enter.
3: The response will resemble this for systems without the SSH server installed:
username host: ~$ ssh localhost
ssh: connect to host localhost port 22: Connection refused username host: ~$
If the aforementioned is true, you must set up the OpenSSH server. The terminal should remain open, and to install the SSH server, execute the following command:
- install OpenSSH-server ii with sudo apt-get.
- When prompted, enter your superusers password.
- After the disc space prompt, press Enter and Y to let the installation proceed.
By entering the following command, you can determine whether the SSH server is operational on the workstation after the necessary support files have been installed:
sudo service ssh status
If the SSH service is now functioning properly, the response should appear in the terminal something like this:
username@host: -$ sudo service ssh status
Service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh. Service; enabled; vendor preset: enab
Active: active (running) since Fr 2018-03-12 10:53:44 CET; 1min 22s ago Process: 1174 Exec Reload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES
Main PID: 3165 (sshd)
Run the ssh localhost command once more in your terminal prompt to see if the OpenSSH server is configured correctly and will accept connections.
How to use SSH to Connect to a Remote Server in Linux or Windows? When you run the command for the first time, the result will resemble this screen:
username@host:~$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:9jqmhko9Yo1EQAS1QeNy9xKceHFG5F8W6kp7EX9U3Rs. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Enter y or yes to proceed.
Congratulations! You have configured your server to allow SSH connection requests sent by an SSH client running on a different computer.
You can now edit the SSH daemon configuration file, for example, you can change the default port for SSH connections. In the terminal prompt, run this command:
sudo nano /etc/ssh/sshd_config
The configuration file will open in the editor of your choice. In this case, we used Nano.
If you need to install Nano, run this command:
sudo apt-get install nano
Please note that you need to restart the SSH service every time you make any changes to the sshd_config file by running this command:
sudo service ssh restart
How to Use SSH to Connect?
Now that every machine you require has the OpenSSH client and server installed, you can connect securely to your servers from a distance. To do this:
- Run the following command after opening the SSH terminal on your computer: SSH to “your username@host ip address”
- You can simply type: ssh host ip address and press Enter if the username on your local machine and the one on the server you are trying to connect to match.
- Enter your password after you’ve typed it. Keep in mind that when typing, there won’t be any feedback on the screen. Make sure your password is securely stored and not in a text file if you are pasting it.
- A server will ask you if you want to keep connecting when you connect to it for the first time. Just enter yes after typing it. Given that the remote server is not recognized on your local PC, this notice only occurs this time.
- You have now connected to the remote server and an ECDSA key fingerprint has been added.
It is recommended to utilize the private IP address rather than the public IP address if the machine you are attempting to remotely connect to is also on the same network. If not, you must only utilize the public IP address.
Additionally, confirm that the port forwarding settings are accurate and that you are aware of the correct TCP port that OpenSSH uses for connection requests. If no changes were made to the configuration in the sshd config file, the default port is 22. The host IP address may also be followed by the port number.
How to use SSH to Connect to a Remote Server in Linux or Windows? The connection request using the OpenSSH client is demonstrated below. We will also mention the port number:
username@machine: ~$ ssh email@example.com –p7654 firstname.lastname@example.org’s password:
The authenticity of host '18.104.22.168 (22.214.171.124)' can't be established. ECDSA key fingerprint is SHA256:9lyrpzo5Yo1EQAS2QeHy9xKceHFH8F8W6kp7EX2O3Ps. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ' 126.96.36.199' (ECDSA) to the list of known hosts.
Now that you have a terminal, you can manage and control a distant machine. If you experience connectivity issues with a remote server, confirm that:
- The remote computer’s IP address is accurate.
- There are no firewall restrictions or erroneous port forwarding on the port the SSH daemon is listening on.
- Your password and username are both valid.
- The SSH program has been correctly installed.
The majority of users and most Linux and Windows operating system versions will be able to use the procedures and actions specified in this guide. Now, either Linux or Windows should be able How to use SSH to Connect to a Remote Server in Linux or Windows?
Of fact, there are a tonne more ways to connect two remote computers, but the ones we’ve covered here are the most typical.