Quick SSH access to your Linux Without Password

Tired of always typing in your password and ssh <thing>@<otherthing>. I’ve got a quick fix for you !

Check for existing SSH keys

In case you’ve got another SSH keys, you can check it with this command below:

ls ~/.ssh

If you don’t see a thing, I’ve got your back !

Generate new SSH keys

To generate new SSH keys enter the following command:

ssh-keygen

Copy your public key to your linux remote computer

To copy your public key to your linux machine, use the following command to append the public key to your authorized_keys file, sending it over SSH:

ssh-copy-id <USERNAME>@<IP-ADDRESS>

Then type in your password, and success !

Quick ssh your remote computer.

giphy
It’s not lazy if it’s a command right ?

From time to time you need to access your remote computer with the basic ssh command, but you’ll get a little lazy!

echo "alias <NAME>='ssh <USERNAME>@<IP-ADDRESS>'" >> ~/.bashrc

This will append an alias in your .bashrc. For example, I connect to my raspberry pi.

echo "alias rpi='ssh pi@raspberrypi.local'" >> ~/.bashrc

To load the changes in your current terminal:

source ~/.bashrc

As example to mine, whenever I need to connect to my Raspberry pi, I simply do this:

rpi

I will get connected to my Raspberry Pi quickly and passwordless !

Advertisements

4 comments

  1. This is kinda disturbing. If all you need to do to log into a Raspberry Pi SSH server is arbitrarily generate a new key or check for unencrypted keys left behind on another computer, doesn’t that make the Pi extremely insecure? I’m genuinely interested in hearing back from you on this question, because I have an RPi SSH server too and am now afraid it might get hacked. D8

    Liked by 1 person

    • Great question! In fact, your ssh server will be accessed only through your computer.

      By itself, SSH is secure. This is trick I’m sharing will simply allow ONLY your computer, ONLY IF you know the password the first time.

      So you can reproduce the step, you will notice you have to know your server password to enable this.

      If someone really wants to access your linux server, he needs to know your password, if it is not the case the person will have to try to connect to your personal or work computer. And I dont think you let your computer passwordless. I hope it helps you 🙂 for any question let me know !

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s