This is a beginner's guide to set up SSH connection on a remote server using Password Authentication in Linux.
What is SSH and Why we need it?
SSH stands for Secure Shell which is based on client-server protocol, An SSH client program is typically used for establishing secure connections between computers. If you want code execution or transfer files into a remote machine or server in a secure way in the Internet, SSH is the best way to do that. There are many applications of SSH like
- Secure remote access to resources
- Delivery of software patches and updates
- Secure File transfer (sftp) etc.
Enough theory Let's jump into the practical part.
Installation of SSH
Most of the Linux Distribution comes with SSH installed within it but if not we can install OpenSSH server easily using this command
$ sudo apt install openssh-client openssh-server
Important: If you are not in a Debian/Ubuntu based distro change "apt" according to your distribution's package manager.
Pro-tip: If you system uses systemD as init system and booted with systemD you can use
systemctl command. OtherWise Google for specific command.
Checking Status of sshd
Let's check SSH daemon is running/active or not in our system, this can be done by this command
$ sudo systemctl status sshd
$ sudo service ssh status
if the service is inactive/dead , start the service using this command
$ sudo systemctl start sshd
$ sudo service ssh start
Configuration of ssh
We don't need to deep dive into ssh config just take a look at some important configuration stored in the
/etc/ssh/sshd_config file. Open the file in a text editor, i'm using vim
sudo vim /etc/ssh/sshd_config
by default, SSH uses port 22
If Password Auth is disabled by default , turn it on
and turn X11 forwarding on
$ sudo systemctl restart sshd
Connect SSH into remote Machine
$ ssh remote-username@remote-ip
It will prompt you to enter password of the machine type the password & you should be in the server :)
incase if you are not familiar with CLI you can find ip by
$ ifconfig or
$ ip a command
Commands at a glance
$ sudo apt install openssh-client openssh-server $ sudo service ssh status $ sudo service ssh start $ sudo systemctl restart sshd $ ssh remote-username@remote-ip $ ifconfig
Top comments (0)