• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
Maker Hacks

Maker Hacks

Ideas, news & tutorials for makers and hackers – Arduino/Raspberry Pi, 3D printing, robotics, laser cutting, and more

  • Home
  • About
  • YouTube
  • Recommendations
  • Contact

Password-Less SSH Access to Your Linux Machine or Raspberry Pi Using Public Keys

You are here: Home / Hacks, Tips, and Tutorials / Password-Less SSH Access to Your Linux Machine or Raspberry Pi Using Public Keys
FacebookTweetPin
Author: Chris Garrett

Password-Less SSH Login Linux

If you are logging in and out of a Linux machine, especially a Raspberry Pi on your local network, it can be a pain to keep entering a password. The longer and more secure your password, the more of a pain it can be. If only there was a secure but convenient alternative …

Well, there is!

SSH and Public Keys

What we are going to do is set up a trusted kind of authentication for our shell access between the two computers. Technically we are creating what is called a “2048 bit RSA key pair”. A bit like a super-password that you don’t have to type in every time 🙂

The Steps

First, we need to see if you already have a key on your local machine by logging into your local terminal and using:

ls ~/.ssh

If you don’t see a .pub file then you need one extra step. Enter:

ssh-keygen

to create one (just accepting the defaults is fine as prompted, unless you are more knowledgeable). You will get a couple of new files.

id_rsa.pub is your public key, which is what you share with the world.

Keep any other files private, especially your id_rsa, which is your private key.

Next, you need to output your file to the terminal so you can copy it to your clipboard, or you can FTP it up to the server if that is easier.

cat ~/.ssh/id_rsa.pub

Copy and paste to the terminal as part of this command:

echo ssh-rsa [YOUR COPYPASTE HERE] >> ~/.ssh/authorized_keys

This appends the key to your Authorized Keys file, essentially saying you get to log in without entering a password in future 🙂

(If the directory does not exist then mkdir ~/.ssh and try again)

Finally, set the permissions:

chmod 600 ~/.ssh/authorized_keys

That’s it, you should now have freedom from passwords, at least between those two SSH terminals 😉

  • Image Source: BigStock

Related

Category: Hacks, Tips, and TutorialsTag: geek, linux, making, programming, technology
FacebookTweetPin

About Chris Garrett

Marketing Director by day, maker, retro gaming, tabletop war/roleplaying nerd by night. Co-author of the Problogger Book with Darren Rowse. Husband, Dad, 🇨🇦 Canadian.

Check out Retro Game Coders for retro gaming/computing.

☕️ Support Maker Hacks on Ko-Fi and get exclusive content and rewards!

Previous Post:Prusa mk42 cloneFinally, Prusa Mk42 Heatbed for the Prusa Mk2/Mk2.5, and Pinda Sensor Clones!
Next Post:Linux Automation Tips: Running Scripts AutomaticallyLinux Automation Scheduling and Starting Scripts on Boot

Sidebar

  • Facebook
  • Twitter
  • Instagram
  • YouTube

Recently Popular

  • Gweike Cloud Review
  • How to choose the right 3D printer for you
  • Glowforge Review – Glowforge Laser Engraver Impressions, Plus Glowforge Versus Leading Laser Cutters
  • Original Prusa i3 Mk3S Review
  • Best 3D Printing Facebook Groups
  • Elegoo Mars Review – Review of the Elegoo Mars MSLA Resin 3D Printer
  • Glowforge ‘Pass-Through’ Hack: Tricking the Front Flap of the Glowforge with Magnets to Increase Capacity
  • How to Make a DIY “Internet of Things” Thermometer with ESP8266/Arduino
  • Wanhao Duplicator i3 Review
  • IKEA 3D Printer Enclosure Hack for Wanhao Di3
  • Creality CR-10 3d printer review – Large format, quality output, at a low price!
  • 3D Printed Tardis with Arduino Lights and Sounds
  • Anet A8 Review – Budget ($200 or less!) 3D Printer Kit Review
  • Make your own PEI 3D printer bed and get every print to stick!
  • Upgrading the Wanhao Di3 from Good to Amazing
  • How to Install and Set Up Octopi / Octoprint
  • Creality CR-10 S5 Review

Copyright © 2023 · Maker Hacks · All Rights Reserved · Powered by Mai Theme