Automatic OpenSSH Login quick guide [Windows to DietPi]

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
Salty Wagyu
Posts: 10
Joined: Thu Oct 14, 2021 1:42 pm

Automatic OpenSSH Login quick guide [Windows to DietPi]

Post by Salty Wagyu »

If you want automatic OpenSSH login when opening a terminal to DietPi from windows, I keep this condensed guide in my notes:

Open Powershell and type:

Code: Select all

ssh-keygen -t rsa -b 4096
and follow the instructions


In your dietpi terminal, go to your Home directory of user (example: john) by typing:

Code: Select all

cd ~
then type the following:

Code: Select all

mkdir .ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Open Powershell and type:

Code: Select all

type $env:USERPROFILE\.ssh\id_rsa.pub | ssh 192.168.1.100 "cat >> .ssh/authorized_keys"
Replace 192.168.1.100 with your dietpi address. It will also ask you to login just this once.


Next, we install the SSH Agent on Windows to allow us to autologin. Open Powershell Admin and type:

Code: Select all

Get-Service ssh-agent | Set-Service -StartupType Manual
Change Manual to Automatic at your own risk, if you want it to start when Windows boots.

Start the service:

Code: Select all

Start-Service ssh-agent
This should return a status of Running:

Code: Select all

Get-Service ssh-agent
Now load your key files into ssh-agent (Change John for your windows username):

Code: Select all

ssh-add C:\Users\John\.ssh\id_rsa
It should now autologin when opening an SSH session.
Post Reply