SSH (Secure Shell) allows secure remote connections between two systems. With this cryptographic protocol, you can manage machines, copy, or move files on a remote server via encrypted channels.
There are two ways to login onto a remote system over SSH – using password authentication or public key authentication (passwordless SSH login).
In this tutorial, you will find out how to set up and enable passwordless SSH login.
Prerequisites
- Access to command line/terminal window
- User with sudo or root privileges
- A local server and a remote server
- SSH access to a remote server via command line/terminal window
Before You Start: Check for Existing SSH Keys
You may already have an SSH key pair generated on your machine. To see whether you have SSH keys on the system, run the command:
Create a private-public key pair
We can create a private-public key pair using ssh-keygen. Execute the following command on your server:
1 |
ssh-keygen -t rsa |
This generates a private-public key pair on your computer. Press enter 3 times to choose the default options.
Deploy ssh key on your server
Login to your server using ssh(preferably non-root user) and password and execute the following command:
Add SSH key for new user
Navigate to the new users home folder and create a file at ‘.ssh/authorized_keys’ and paste in the key
1 2 3 4 5 |
cd /home/dydevops mkdir .ssh cd .ssh nano authorized_keys Paste the key and hit "ctrl-x", hit "y" to save and "enter" to exit |
OR
This will create a .ssh in the home directory (‘/home/dydevops/’ in my case) of your user. DigitalOcean droplet ships with a root account so creating this ‘.ssh’ directory is not needed if you want to configure serverless login for root.
Execute the following command on your host computer
1 |
scp C:/Users/Dharmendra/.ssh/id_rsa.pub dydevops@139.59.29.122:~/.ssh/authorized_keys |
Replace ‘C:/Users/Dharmendra’ with your user home directory on Windows. You will be prompted for the password. Enter your password and your ssh key will be deployed.
Test your passwordless login
Try to log into your server by entering the following command. Replace user with your username and ip-address with your server’s ip address
1 |
ssh user@ip-address |
Download and install Filezilla
FileZilla Client is a fast and reliable cross-platform FTP, FTPS, and SFTP client with lots of useful features and an intuitive graphical user interface. Download this free software from here
Install Filezilla on your computer and open it.
Login to your server using FileZilla
Enter your server IP, username, and password inside the boxes at the top in FileZilla. Make sure your enter 22 as the port. Press enter and wait for some time.
Uploading files to your server
You can now upload files to your server by navigating to the directory of your choice and dragging/dropping your files into the folder(on your server) of your choice.