Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8374

Beginners • Re: On/Off Switch for Raspberry Pi 4

$
0
0
I was getting mixed up so I decided to start from scratch. I deleted the keys from Pi and Windows. I then followed the below. I had to cut and paste it together so I hope its right.

Code:

Here's the procedure from a windows host using NO other tools than just windowsOpen CMD and typeCode: Select allssh-keygenpress enter* do not use a passphrase for a start (you can add one later) so press enter twice moreThat's it ! You have your key pair createdCheck your personal .ssh folder, like : C:\Users\YOURUSERNAME\.ssh\You can see- your private key : id_ed25519- your public key : id_ed25519.pubFYI : ED25519 keys are more secure and performant than RSA keys but it's fundamentally the same thingOn windows you now have your key pair generated. Open CMD and type Code: Select allssh YOURRPIUSERNAME@YOURRPIorssh YOURRPIUSERNAME@IPADDRESS> we want to make sure you can ssh your PI using your password (if this doesn't work, we'll have to adjust your ssh settings on the pi)> you will be warned to confirm you want to connect and prompted for your passwordAfter successful login, type Code: Select allexitto end the ssh connectionNow you're back to windows CMD terminalCode: Select allcd .ssh> you need to be in C:\Users\YOUR-USERNAME\.ssh Code: Select alldir> will show the content of the folder, you should see your private and public keys. If OK, type Code: Select allscp id_ed25519* YOURRPIUSERNAME@YOURRPI:~> scp is part of ssh, it means Secure Copy> here we copy your key pair to your home folder on the Pi, you will be prompted for your pi password> you should be confirmed the copy is ok.Now you have 2 options: keep on working from your windows host or login physically on your piOption 1 : still in Windows CMD terminal, connect with SSH + password to your PI (liek before) Code: Select allssh YOURRPIUSERNAME@YOURRPIorssh YOURRPIUSERNAME@IPADDRESSOn success, type Code: Select allls> you should see your keys at the root of /home/YOUR-USERNAMEYour PI has ssh-copy-id command by default so the final step is simply to type Code: Select allssh-copy-id -f -i C:\Users\YOURUSERNAME\.ssh\id_ed25519.pub YOURRPIUSERNAME@YOURRPIFor me it would be : ssh-copy-id -i C:\Users\dwam\.ssh\id_ed25519.pub dwam@rpi5 (or dwam@192.168.0.25 - if you cannot resolve name to IP)Press enter> the -f parameter is used to force the copy> again you should be asked to confirm> and you should see : Number of key(s) added: 1Almost finished ! Type Code: Select allcat ~/.ssh/authorized_keys> and you should see 1 line starting with ssh-ed25519 ....If OK, type Code: Select allexitYou're back in WIndows and now you can test to ssh your Pi without password Code: Select allssh YOURRPIUSERNAME@YOURRPIorssh YOURRPIUSERNAME@IPADDRESSIf successful, you NEED to delete the key pair from your home folder Code: Select allrm ~/id_ed25519*And now you can control your PI from your windows host with SSH and pubkey authentication Still in CMD terminal, type : ssh YOURRPIUSERNAME@YOURRPI (or IP address)You should be logged in with no password, ready to go 
The issue Im running into is with

Code:

ssh-copy-id -f -i C:\Users\YOURUSERNAME\.ssh\id_ed25519.pub YOURRPIUSERNAME@YOURRPI
Its telling me there is no file but I can see the file. I tried without the -f but the result is the same.

Image


Here it is in CMD:

Image

Statistics: Posted by russ8585 — Sat Nov 08, 2025 11:29 pm



Viewing all articles
Browse latest Browse all 8374

Trending Articles