This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has
sudoaccess and that you precede each of the privileged commands with
There are many ways to establish a connection with a remote machine depending on the operating system you are running, but the two most used protocols are:
- Secure Shell (SSH) for Linux-based machines
- Remote Desktop Protocol (RDP) for Windows-based machines
Secure Shell (SSH) is a commonly used protocol to gain remote access through a command line interface. Administrators with advanced knowledge may use SSH to log in to a web server and perform tasks such as file and folder transfers, disk usage reviews and performance monitoring, using commands such as top).
To connect to a SSH server on your linux, you first need to install OpenSSH Client on your system.
Installing OpenSSH Client
Run the following command to install the OpenSSH client on your linux:
[email protected]:~$ apt-get install openssh-client
Installing OpenSSH Server
Run the following command to install the OpenSSH server on your linux:
[email protected]:~$ apt-get install openssh-server ii.
Verifying Installation Of OpenSSH Client
You can type the following command to verify the installation of OpenSSH Client on your system. If the OpenSSH Client is installed on your system, the output will look like this:
[email protected]:~$ ssh 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 [[email protected]]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]] [[email protected]]hostname [command]
Verifying Installation Of OpenSSH Server
You can type the following command to verify the installation of OpenSSH Server on your system. If the OpenSSH Server is installed on your system, the output will look like this:
[email protected]:-$ service ssh status • ssh.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 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES Main PID: 3165 (sshd)
Following is the general syntax of the OpenSSH
[email protected]:~$ ssh [username]@[hostname]
[email protected]:~$ ssh [email protected] [email protected]'s password: The authenticity of host '126.96.36.199 (188.8.131.52)' can't be established. ECDSA key fingerprint is SHA256:9lyrpzo5Yo1EQAS2QeHy9xKceHFH8F8W6kp7EX2O3Ps. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ' 184.108.40.206' (ECDSA) to the list of known hosts. [email protected]:~$
You’ll see a message asking you to confirm the identity of the server the first time you connect. If this is actually the first time you connected to the server, this is normal and you can type “yes” to continue.
VNC Over SSH
For users who are used to working in a graphical desktop environment with Virtual Network Computing (VNC), it is possible to completely encrypt connections using SSH tunneling. In order to tunnel VNC connections over SSH, you will need to run this command in the terminal on your Linux or UNIX machine:
[email protected]:~$ ssh -L 5901:localhost:5901 -N -f -l username hostname_or_IP
The Windows Command Prompt application does not support SSH by default. We recommend downloading a third-party application such as PuTTY, which includes SSH support.
Download & Install PuTTY
Click Here to download PuTTy and then install it on your windows.
After successful installation of PuTTY, open PuTTY desktop application.
Enter your server connection settings:
- Host Name: example.com OR 220.127.116.11 (change it to the IP of your server)
- Port: 22 (leave as default)
- Connection Type: SSH (leave as default)
You’ll see a security alert the first time you try to connect to a server. This tells you that you haven’t previously connected to this server. That’s expected, so click “YES” to continue.
You’ll be prompted to enter the username and password for your account on the SSH server. After you do, you’ll be connected. Just close the window to end the SSH connection.
The procedure to connect to a server through SSH in mac is same as in linux.
Open the terminal and run the following command:
[email protected]:~$ ssh [username]@[hostname]
Change the [username] to your username and [hostname] to the name of the host or the IP of the host.
Last login: Mon July 22 20:27:32 on ttys000 Codesposts-Macbook-Air:~ root$ ssh [email protected]
You’ll be asked if you wish to continue connecting. Enter yes. Then you will be prompted for your password. Enter the password and you will be connected to your server.