How to prepare SD card (or image) of fresh Raspbian (under Linux), so:
- it has enabled sshd
- has set password to one I provide
so device is ready to go, i.e. I plug MicroSD card, attach ethernet cable, power, and I can ssh and continue rest of configuration via ssh.
Please assume I use Linux as desktop, and that I have mounted MicroSD card or image under ${ROOTMNT?}
.
(To be clear: I want to omit step requiring to connect raspberry to monitor via hdmi and keyboard. I am looking for script, process is automated.)
ssh
file in the boot partition, which is what you want to do. Setting a password without running the system first is, I think, not impossible but it is a bit convoluted because the password is not stored anywhere, a one way hash of it is. It will be much simpler if you just log in the first time with the default password and then change it. – goldilocks Feb 03 '17 at 12:26/etc/passwd
and/etc/shadow
into the corresponding files on the SD card. I think I've done that before and it's worked (I guess it depends whether they use the same hashing method, which they probably do). Worth a try anyway. There is no record of users beyond those two files (excluding stuff they own such as a home directory, which you would also want to create with the correct UID/GID). – goldilocks Feb 03 '17 at 13:36Otherwise, I will disallow password authentication on ssh and only allow public/private key authentication and put credentials in .ssh/authorized_keys .
Thanks!
– Grzegorz Wierzowiecki Feb 03 '17 at 15:21