Alan Santos

Software Engineer

Enabling and configuring SSH on Raspberry Pi OS

In this tutorial, I will show how can you enable SSH on Raspberry Pi OS. SSH aims to facilitate the access of your system command line from another computer. In my case, I use a MacBook, and I configure my Raspberry Pi without need any device plugged on it, only the power adapter.

On the Rapberry Pi OS, press Ctrl+Alt+T to open the terminal and type the commands bellow:

sudo systemctl enable ssh 

sudo systemctl start ssh

The first command you enable the SSH service and the second command will start SSH

Access Raspberry Pi OS from another computer using SSH

Using Linux, Mac and Windows 10 (most current versions) you use the terminal or prompt (Windows) to use SSH. Just type the command ssh [email protected] type your password as requested and done!

192.168.15.26 is my Raspberry Pi IP Address. You can find you IP, just typing hostname -I in the Raspberry Pi OS terminal.

On old versions of Windows, you will need to use PuTTY SSH client. You can check here how you can install and use it

Configuring SSH public/private key on your computer

If you want to access the Raspberry Pi using SSH, but don’t wanna type the password giving up security, you can use SSH public/private key to access like the image bellow:

To generate the private/public key:

  1. run the command ssh-keygen
  2. Enter a passphrase if you want. If not, just press enter
  3. Confirm your passphrase, or just press enter for no password

Configure public key on your Raspberry Pi OS

  1. Run the command cat ~/.ssh/id_rsa.pub to get the public key
  2. Copy the key exposed by the command cat
  3. Enter on Raspberry Pi OS using the command ssh pi@YOUR_IP_ADDRESS
  4. Run the command mkdir ~/.ssh && touch ~/.ssh/authorized_keys to create .ssh folder and the authorized_keys file
  5. Run the command nano ~/.ssh/authorized_keys to edit the file
  6. Paste the public key exposed on step 2
  7. Press Ctrl+X and Enter to write
  8. Press Y to confirm the write on the file and run the command exit to close the SSH connection with Raspberry Pi OS
  9. Now you can connect into your Raspberry Pi OS without type any password using the same command ssh pi@YOUR_IP_ADDRESS

For older versions of Windows, Cmder can help you with run unix commands on Windows and PuTTY to generate the SSH key.


That’s it for now! I’m very happy to help you to configure Raspberry Pi OS SSH. Bye!

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
EnglishPortuguês
0
Would love your thoughts, please comment.x
()
x