Simplify remote server access with auto SSH login

Sep 10, 2022·

2 min read

Play this article

Table of contents

No heading

No headings in the article.

SSH (Secure Shell) is a powerful tool for remote access and management of Linux servers. However, manually entering login credentials every time you want to access a server can be a hassle. In this tutorial, we'll show you how to set up auto SSH login on a Linux machine, so you can log in without entering your password every time.

Step 1: Generate SSH Key Pair The first step is to generate an SSH key pair on the client machine. Open the terminal and run the following command:

ssh-keygen -t rsa

You'll be prompted to enter a file name and location for the key pair. You can leave the default settings and press Enter.

Step 2: Copy Public Key to Server Next, you need to copy the public key to the server you want to log in to. Use the following command to copy the public key to the server:

ssh-copy-id user@server_ip_address

Replace "user" with the username you want to log in as and "server_ip_address" with the IP address of the server.

Step 3: Test SSH Login Now you can test your SSH login. Use the following command to log in to the server:ssh user@server_ip_address

You should be able to log in without entering your password.

Step 4: Edit SSH Config File Finally, you can edit the SSH config file to enable auto login. Open the config file using the following command:

nano ~/.ssh/config

Add the following lines to the file:Host server Hostname server_ip_address User user

Replace "server" with a name for your server, "server_ip_address" with the IP address of the server, and "user" with the username you want to log in as.

Save the file and exit.

Step 5: Test Auto SSH Login Now you can test the auto login feature. Use the following command to log in to the server:

ssh server

You should be able to log in without entering your password.

Congratulations, you have successfully set up auto SSH login on your Linux machine! This will save you time and make it easier to manage your servers remotely.