Passwordless SSH Linux Setup Guide
To set up passwordless SSH login on Linux, you can follow these steps:
- Generate an SSH key pair on the client machine. Open the terminal and run the following command:
- Generate a new RSA SSH key.
- This will generate a pair of public and private keys. You can choose to use the default file name and location, or customize it.
- Copy the public key to the server. Run the following command:
- Copy the SSH key to the specified user on the server with the given IP address.
- You will be asked to enter the password for the server, using the username “user” on the server and the server’s IP address as “server_ip”.
- If the ssh-copy-id command is not available, you can manually copy the public key to the ~/.ssh/authorized_keys file on the server.
- Verify the password-free login. Execute the following command:
- Connect to the server with the specified user by using SSH.
- You should be able to log in to the server directly without entering a password.
- Optional: Disable password login (optional, but recommended). Open the SSH configuration file on the server (usually located in /etc/ssh/sshd_config), and locate the following line:
- Enabling password authentication.
- Change it to:
- Disable password authentication.
- Save the files and restart the SSH service.
- Restart the SSH service using sudo.
- Currently, the only way to access the server is by using SSH keys.
Please note that the above steps assume that you already have an SSH client and server, and that you have sufficient permissions on the server.