Monday, February 05, 2024

SSH Controlmaster holding devices

Maybe this is a feature, but I found it strange that an ssh
controlmaster process
will attach itself to a device whose directory you are in when you
create that connection.

For example in my config

Host *
        IdentitiesOnly          yes
        ObscureKeystrokeTiming  yes
        ControlPath             ~/.ssh/controlmasters/%r@%h%p
        ControlMaster           auto
        ControlPersist          60m

If I have a device mounted at /mnt/usb and I am cd'd into that directory and
ssh into a server, the control master will create a file at
~/.ssh/controlmasters.
However, with the file created while cd'd into /mnt/usb, it makes the
device mounted
at /mnt/usb busy and unmountable until that process exits, even though
that process
has no relation to that device aside from having that dir be my pwd when
using ssh.

Steps:

$ mnt /dev/sd3i /mnt/usb
$ cd /mnt/usb
$ ssh example.com
$ cd /
$ umount /mnt/usb
umount: /mnt/usb: Device busy
$ fstat -f /mnt/usb
USER     CMD          PID   FD MOUNT        INUM  MODE R/W    SZ|DV
courtney ssh        40229   wd /mnt/usb        2  drwxr-xr-x r     4096
$ ps -ux | grep 40229
courtney 40229  0.0  0.0  2312  2664 ??  Ip     12:14PM    0:00.00 ssh:
/home/courtney/.ssh/controlmasters/courtney@example.com22 [mux] (ssh)
$ ssh -O exit example.com
Exit request sent.
$ umount -v /mnt/usb
/dev/sd3i: unmount from /mnt/usb

I don't see the point of this happening. Is this expected/desirable
behavior?

Courtney

No comments:

Post a Comment