Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Enable SSH on mounted disk?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Enable SSH on mounted disk?

So I have a microSD card with an Ubuntu OS on it that had as one of it's last commands:

systemctl disable ssh

I can no longer SSH into this drive when it is running as the server on my NanoPI. I can take that microSD card and mount it to a Linux desktop as another drive and get access to the file system no problem. But what would I need to change on the drive to re-enable SSH again?

Comments

  • lionlion Member
    edited January 2018

    ln -s /mnt/sdcard/usr/lib/systemd/system/ssh.service \
    /mnt/sdcard/etc/systemd/system/multi-user.target.wants/ssh.service

    something similar, didn't test

  • Super...yep that was what it needed. Thanks!

  • @geodirk said:
    Super...yep that was what it needed. Thanks!

    Woah something that i said actually worked? Good to hear

    Thanked by 2Falzo PrestigeWS
  • Wouldn't you want the target of the softlink to be relative to the root of the sdcard, so that when you pop it into the Pi it references the right location? Something like (untested):

    ln -s /lib/systemd/system/ssh.service \ /mnt/sdcard/etc/systemd/system/multi-user.target.wants/ssh.service

  • WSSWSS Member

    apt-get install sysvinit

  • geodirkgeodirk Member
    edited January 2018

    @seanho said:
    Wouldn't you want the target of the softlink to be relative to the root of the sdcard, so that when you pop it into the Pi it references the right location? Something like (untested):

    ln -s /lib/systemd/system/ssh.service \ /mnt/sdcard/etc/systemd/system/multi-user.target.wants/ssh.service

    I changed into the source dir first and then ran the command. It worked and SSH was restored on the next boot.

  • Off the top of my head....

    You could try using chroot to set the mount as root, which should allow you to use systemctl to enable ssh. Something like chroot /mnt/sdcard /bin/bash -i then systemctl enable ssh.

    I might have left out a couple of steps.

  • WSSWSS Member
    edited January 2018

    @flatland_spider said:
    Off the top of my head....

    You could try using chroot to set the mount as root, which should allow you to use systemctl to enable ssh. Something like chroot /mnt/sdcard /bin/bash -i then systemctl enable ssh.

    I might have left out a couple of steps.

    You left out many, Mr. Merzbow.

    # mount -t proc proc /mnt/{...}/proc

    # mount -t sysfs sys /mnt/{...}/sys

    # mount -o bind /dev /mnt/{...}/dev

    # mount -t devpts pts /mnt/{...}/dev/pts

    ..just off the top off my head. It's certainly easier for him to have gone to a relative directory and created the link there, without worrying about the wrong systemd running somehow breaking a symlink and whatever else.

  • @WSS said:
    # mount -t proc proc /mnt/proc

    # mount -t sysfs sys /mnt/sys

    # mount -o bind /dev /mnt/dev

    # mount -t devpts pts /mnt/dev/pts

    ..just off the top off my head. It's certainly easier for him to have gone to a relative directory and created the link there, without worrying about the wrong systemd running somehow breaking a symlink and whatever else.

    >

    That looks correct. I usually look up the Gentoo install instructions to get everything.

    It would only be a bad symlink. Systemd doesn't do anything crazy when enabling services, so it has that going for it.

    Of course if they just used a text file to control service init, this wouldn't even be a problem. Mount disk, edit text file. :\

Sign In or Register to comment.