m4ts5
Posts: 2
Joined: Sat Jan 12, 2019 12:15 pm

install ssh server on Raspbian Stretch Lite, i only have access to the sd card

Sat Jan 12, 2019 12:28 pm

yesterday i tried to install gitlab, but it wasnt working with my already installed apache server, so i removed it.
I installed it with this command: sudo apt-get install curl openssh-server ca-certificates postfix apt-transport-https.
and removed it with the same command but remove instead of install: sudo apt-get remove curl openssh-server ca-certificates postfix apt-transport-https.
now i have no access to the raspi via ssh, but to the sd card i installed raspian on. i can read and modify files.
I'd like to know how i install the ssh server.
i already thought about running the install command at boot, but i dont know how i would do this.

Any help is appreciated

wh7qq
Posts: 1237
Joined: Thu Oct 09, 2014 2:50 am

Re: install ssh server on Raspbian Stretch Lite, i only have access to the sd card

Sat Jan 12, 2019 8:12 pm

The prescribed way (if you read the instructions) is to add the text file named "ssh" to the top directory of the boot partition (small FAT partition on the SD card), or to enable it via "raspi-config" or the top menu configuration item on the desktop. See https://www.raspberrypi.org/blog/a-secu ... ian-pixel/ for more info. If the RPi still boots from that SD card and you can access raspi-config, that would be your best bet. Above all, if you enable access to the RPi from the net in any way, change your password from the default to something much more complex.

drgeoff
Posts: 9137
Joined: Wed Jan 25, 2012 6:39 pm

Re: install ssh server on Raspbian Stretch Lite, i only have access to the sd card

Sat Jan 12, 2019 9:01 pm

You don't need to install ssh server. It is already present but needs to be enabled as described above.

fbe
Posts: 427
Joined: Thu Aug 17, 2017 9:08 pm

Re: install ssh server on Raspbian Stretch Lite, i only have access to the sd card

Sat Jan 12, 2019 11:50 pm

Of course you need to reinstall ssh server if you accidently removed it.

If you have a card reader connected to your raspberry pi you could boot from a new image, then mount your damaged installation and chroot into it. Otherwise you could place commands into /etc/rc.local of your damaged image. You should test it with a copy of your damaged system first or remove the ssh server from a new Raspbian installation and try to repair that.

Code: Select all

apt install -y ssh
systemctrl enable ssh
systemctrl restart ssh
should be the needed commands.

If you are in a chroot environment, don't run "systemctrl restart ssh".

m4ts5
Posts: 2
Joined: Sat Jan 12, 2019 12:15 pm

Re: install ssh server on Raspbian Stretch Lite, i only have access to the sd card

Sun Jan 13, 2019 12:44 pm

@fbe
Thanks a lot, this is what i needed!

Return to “Troubleshooting”