1

First, I precise that I was able to ssh on this machine (I think an embedded system based on Debian 7), but I had to set / to read-only to prevent any power off problems. I verified that /tmp, /var/log, /var/lock are still writeable, but the /home folders where I'm not supposed to write anything in normal execution are read-only.

Anyway, an ssh root@ip_address fails with ssh: connect to host ip_address port 22: Connection refused message.

ssh -v ... tells:

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "192.168.32.30" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.32.30 [192.168.32.30] port 22.
debug1: connect to address 192.168.32.30 port 22: Connection refused
ssh: connect to host 192.168.32.30 port 22: Connection refused

Could you please tell me why and how to fix it?

EDIT: Here is how I set my FS to RO:

Original fstab file:

/dev/mmcblk0p2       /                    auto       defaults          1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0
/dev/mmcblk0p3       /data                auto       defaults,sync              0  1

Modified fstab file: (I only changed the first line)

/dev/mmcblk0p2       /                    auto       ro            1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0
/dev/mmcblk0p3       /data                auto       defaults,sync              0  1

EDIT 2:

I answered to someone that I can effectively access with ssh if the filesystem is rw. This is not exactly true. If I boot with option ro in fstab and then remount / in rw, I cannot access with ssh. It works if I change option back to default and reboot.

  • Does it work again if you remove the read only restriction? – bxm Nov 18 '19 at 16:14
  • @bxm, just verified and yes but I've edited my post to give information about how I set the fs to ro. in case.... – fralbo Nov 18 '19 at 16:41
  • Doesn’t look like /tmp is its own file system from your fstab, which as per EchoMike444 is not going to end well. – bxm Nov 18 '19 at 18:19
  • Can you log in without SSH (e.g. locally) and confirm that the SSH server runs and listens where it should? – Kamil Maciorowski Nov 19 '19 at 8:37
2

Ok, so many thanks to everybody (EchoMike444, iLkkachu, Kamil Maciorowski) for pointing me to the right direction.

In fact I didn't precise that my sshd is dropbear and this one needs to write to /var/lib to start.

So I had to add this mount point to tmpfs to be able to connect to my target via ssh.

1

ssh need to write into /tmp .

Your /tmp/ is in a / mount .

if you run df /tmp it will display your / mount point , and you can check that df /run is a different mount point .

  • I don't think it could be the reason because both /tmpand /run are mounted as tmpfs in rw mode and in fact I can write in /tmp even if / is ro. but in I edited my post again because the problem may come from something else. – fralbo Nov 19 '19 at 8:22
  • You may be right in fact as I can effectively write to /tmp once started up but I guess that tmpfs is started too late for dropbear. Is it possible? – fralbo Nov 19 '19 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.