![]() |
[How to do instruction] How to hardening your ssh access to MoOde HW - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9) +--- Thread: [How to do instruction] How to hardening your ssh access to MoOde HW (/showthread.php?tid=3244) |
How to hardening your ssh access to MoOde HW - UpsiUps - 12-11-2020 I assume you allready have enabled ssh by a file called "ssh" on your SD-card ( File could be empty and easy generated with Code: touch /<mountpoint of SD Card/ssh Now you could log into MoOde with the standard password as user pi To harden the ssh entrance you won't allow passwords in the future. Instead you use a pair of keys taht you generate with ssh-keygen. E.G like Code: host% ssh-keygen ![]() As you currently logged in to your MoOde HW as user pi with the password, you could now copy the public key to your MoOde HW: Code: host% cd .ssh When you never ssh'ed the MoOde HW, ssh will ask you , if that HW is really the HW you want to contact and will show you a fingerprint of the host-key. In my case ssh is also asking the DNS system for a so called host-key of the ssh daemon running on the MoOde HW. When you are sure that it is your HW, the host-key will be stored in your ~/.ssh/known_hosts file so that you won't be bothered next time ( as long as the host-key has not changed - but that is a different story ) The password you need to enter is the password you use for user pi Now the key is copied to the root directory of your moOde HW. and it is time to log in to the MoOde HW: The first step is to move the key into ther right place Code: host% ssh pi@moode.example.com Now you could allready login without a password to your moOde HW. Lets try it: Code: pi@moode:~ $ exit Now you need to prevent that others still could login with a password. To do so , you need to edit /etc/ssh/sshd_config You need to change the following keywords:
Code: pi@moode:~ $ sudo vi /etc/ssh/sshd_config That's it ! Now you could only login from host to your moode system. You could verify this by using a diffrent user or system and try to login to your moode system. You will see Permission denied (publickey). as a return to your try.. Addition: if you want to login from other systems via ssh to your MoOde HW, you need to repeat this procedure with one diffrence: instead of copiing the public key into the authorized_keys file, you need to add the key: mv id_rsa.pub >>.ssh/authorized_keys [2nd Addition] E.g. if our user name on the host is BestDJ a simple ssh moode.example.com will not allow you to login as ssh tries to do BestDJ@moode.example.com instead of pi@moode.example.com. To allow you to shortcut the ssh command, do the following Code: cd |