Do you log in to your Linux server frequently? Tired of entering your password every time? With SSH key-based authentication, you can streamline your workflow by logging in securely without a password.
In this guide, we’ll show you how to set up password-less SSH login in just two steps using ssh-keygen and ssh-copy-id.
What Is Password-less SSH Login?
Password-less SSH login uses public key cryptography to authenticate your access. Instead of typing a password, you use an SSH key pair—one private (stored on your machine) and one public (stored on the server). It’s fast, convenient, and much safer than using passwords alone.
Step 1: Generate an SSH Key Pair
Open a terminal on your local machine and run:
ssh-keygen
You will be prompted:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/yourname/.ssh/id_rsa):

Simply press Enter to accept the default location.
When asked for a passphrase, you can either:
- Press Enter again for a completely password-less login
- Or enter a secure passphrase for additional protection
This will generate two files:
~/.ssh/id_rsa(your private key – keep this secret!)~/.ssh/id_rsa.pub(your public key – safe to share with the server)
Step 2: Copy the Public Key to Your Server
Run the following command to upload your public key to the remote server:
ssh-copy-id username@server_ip
Replace:
usernamewith your actual Linux username on the remote serverserver_ipwith your server’s IP address or domain
You’ll be asked to enter your server password one last time. Once complete, the public key will be added to the server’s ~/.ssh/authorized_keys file.
Step 3: Test the Password-less Login
Now try logging in again:
ssh username@server_ip
If everything went well, you’ll log in without needing to enter your password!
🔍 Behind the Scenes: How It Works
Here’s what’s happening:
- Your SSH client sends a request to the server.
- The server checks for your public key.
- If it finds a match, it issues a challenge.
- Your private key answers the challenge.
- The server validates the answer and grants access—no password required!
Best Practices & Tips
- Keep your private key secure. Do not share it.
- Set correct file permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
- Use a passphrase on your key for additional security.
- Consider backing up your keys in a secure, encrypted location.
Extra tip:
Create alias which contain the command to ssh to you remote server:
alias pi = “ssh username@ipaddress”
Now you will be able to connect to your remote server just by typing pi.
To keep this alias permanently on your system add it to your bash settings file.
Conclusion
That’s it! In just a few minutes, you’ve set up a secure, password-less SSH login. This small tweak can save you time and improve your server’s security. Whether you’re managing personal servers or enterprise systems, SSH keys are the way to go.
Happy logging in—no password required! 🧑�