navpi icon indicating copy to clipboard operation
navpi copied to clipboard

Enable ssh without keyboard & monitor

Open noeldum opened this issue 8 years ago • 2 comments

I do not have the kit to connect the pi to keyboard video and mouse. I am not planning to use any of them in the future either. I would always remotely connect.

How can I enable ssh on the SD card without going through the step with keyboard/monitor?

I tried creating an empty ssh file in /boot but that did not work. Is there another alternative?

noeldum avatar Sep 04 '17 21:09 noeldum

I second this request. I don't have a way to connect monitor and keyboard to my Pi Zero W. I don't even own a monitor and a keyboard. Is there a way to enable SSH access at least for the configuration phase?

stefanomattia avatar Dec 02 '17 22:12 stefanomattia

After flashing the image to the SD-card, you could edit /var/spool/cron/crontabs/root and add to the bottom:

@reboot sleep 30 && systemctl start ssh && /usr/sbin/ufw allow 22 @reboot sleep 150 && systemctl stop ssh && /usr/sbin/ufw deny 22

This will start the SSH daemon and open the necessary port in the firewall after booting. A little later it will stop the daemon and close the port (security), meaning you have about two minutes to login every time after rebooting.

Note that you can Reboot the device in the Web Interface of the NavPi: Control -> Power -> Restart StakeBox, in case you ever need root access again. I hope this helps.

Dummann avatar Jan 29 '18 02:01 Dummann