Automount with SSHFS on KDE login (with encrypted home directory) - systemd expert needed

Complicated situation. I have my /home directory encrypted with LUKS, and I use PAM to autotomatically decrypt it and mount it on KDE (SSDM) login. Now I want to also automount several SSHFS remote directories into several subdirectories of my (single user’s on this workstation) home folder. What I have done so far:

  1. I edited my pam.d with “auth optional pam_exec.so expose_authtok /etc/luks_decrypt.sh” so my credentials are passed on to “cryptsetup open /dev/md1 enc_home” etc. This decrypts the encrypted LUKS volume and works fine.
  2. I created a “.mount” systemd unit that “Requires=user@1000.service”. So when my user logs in:

[Mount]
Where=/home
What=/dev/mapper/enc_home

This works fine as well.

Now, AFTER this happens, I want to mount some remote directories from an SSH server to some (empty) directories of the decrypted home folder of the user. Like /home/myuser/remote_server_files_1/, /home/myuser/remote_server_files_2/, /home/myuser/remote_server_files_3/ using a shell script in my home directory.

My problem is that I’m pretty thick with systemd, and it seems that whatever I do tries to mount BEFORE the actual user home has been decrypted and mounted.

Any idea as to what I can do? I also tried KDE’s autostart but it seems it doesn’t work since Plasma 5.21 due to migrating the entire procedure to systemd as well (and I can’t find any documentation as to how it works).

Thank you!

@ReverantGR:

Some StackExchange information: <https://unix.stackexchange.com/questions/730320/systemd-crypttab-and-starting-units-after-decryption>.

Apart from that, you may need to make use of “After=” in your User configuration file –

  • But, “After” what?
    Is there a systemd User service which is performing the decryption on login?

I guess I can try After=decrypted_home.mount and see if that works. Thank you for your input!