0

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.)

  • 1
    The accepted answer to the duplicate refers to placing an `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](http://raspberrypi.stackexchange.com/a/50457/5538). 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
  • for setting password , won't chroot-ing be a solution : http://www.microhowto.info/howto/reset_a_forgotten_root_password_using_a_live_distribution.html ? – Grzegorz Wierzowiecki Feb 03 '17 at 13:26
  • 1
    If you have another linux system to work with, you could do that, but first I would try simply creating the user and the password you want on that system, then copying out the entry for that user from `/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:36
  • Thanks! Sounds like good advice! Otherwise, 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

0 Answers0