Login with SSH-Keys Topic is solved

Having issues with your DietPi installation or found a bug? Post it here.
Klola
Posts: 17
Joined: Tue Jul 20, 2021 5:07 pm

Login with SSH-Keys

Post by Klola »

Hello,

I wanted to log in to DietPi with SSH keys in the future. With puTTYGen I have already created a pub and private key.

Under nano ~/.ssh/authorized_keys I entered my pub key.
Can I use these keys also with Dropbear or only with OpenSSH?

I wanted to create under
- sudo nano /etc/ssh/sshd_config
-RSAAuthentication yes
-PubkeyAuthentication yes
-but found only PubkeyAuthentication

Likewise I wanted to enter
-PasswordAuthentication no
-Execute UsePAM no

Does this also work with Dropbear, or would you rather use OpenSSH directly?

Thanks
User avatar
trendy
Posts: 360
Joined: Tue Feb 25, 2020 2:54 pm

Re: Login with SSH-Keys

Post by trendy »

Klola wrote: Fri Sep 10, 2021 11:10 pm Under nano ~/.ssh/authorized_keys I entered my pub key.
Can I use these keys also with Dropbear or only with OpenSSH?
That's right. It will work with both.
Klola wrote: Fri Sep 10, 2021 11:10 pm I wanted to create under
- sudo nano /etc/ssh/sshd_config
-RSAAuthentication yes
-PubkeyAuthentication yes
-but found only PubkeyAuthentication
PubkeyAuthentication yes is the default value even when commented. The other one with RSA is not found in the default config, but it is not needed.
Klola wrote: Fri Sep 10, 2021 11:10 pm Likewise I wanted to enter
-PasswordAuthentication no
-Execute UsePAM no

Does this also work with Dropbear, or would you rather use OpenSSH directly?
In dropbear you'll have to edit the /etc/default/dropbear and pass all these options as extra arguments.
Klola
Posts: 17
Joined: Tue Jul 20, 2021 5:07 pm

Re: Login with SSH-Keys

Post by Klola »

Thanks @trendy

What is the correct command for disable the root login?
dropbear -g

sudo nano /etc/default/dropbear
RootPasswordAuth=0 from: https://openwrt.org/docs/guide-user/bas ... m/dropbear
or
PasswordAuthentication no

Greetings :)
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Login with SSH-Keys

Post by Joulinar »

you should adjust /etc/default/dropbear and change DROPBEAR_EXTRA_ARGS=-g -w. Restart service afterwards.

https://linux.die.net/man/8/dropbear
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Klola
Posts: 17
Joined: Tue Jul 20, 2021 5:07 pm

Re: Login with SSH-Keys

Post by Klola »

Thanks, after changing the dropbear file I can no longer log on to the raspberry with ssh. Must probably connect monitor/keyboard again and change the config. (Connection refused with putty)

Basically my login works via ssh key file
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Login with SSH-Keys

Post by Joulinar »

could you check if dropbear is still running once connected locally?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Klola
Posts: 17
Joined: Tue Jul 20, 2021 5:07 pm

Re: Login with SSH-Keys

Post by Klola »

2021-09-16 08_35_29-IMG_20210916_083315.jpg - IrfanView (Zoom_ 1553 x 1165).png
User avatar
Joulinar
Posts: 5619
Joined: Sat Nov 16, 2019 12:49 am

Re: Login with SSH-Keys

Post by Joulinar »

Pls remove -w option and restart the service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Klola
Posts: 17
Joined: Tue Jul 20, 2021 5:07 pm

Re: Login with SSH-Keys

Post by Klola »

Thank you @Joulinar
SSH works again, should be fine nowm can't enter my password :)
2021-09-16 09_19_02-192.168.176.30 - PuTTY.png
2021-09-16 09_19_02-192.168.176.30 - PuTTY.png (12.67 KiB) Viewed 23 times
User avatar
trendy
Posts: 360
Joined: Tue Feb 25, 2020 2:54 pm

Re: Login with SSH-Keys

Post by trendy »

Most likely you still have `-g` option which doesn't allow the root to login with password. Either remove that option or login first as dietpi.
Post Reply