files in /dev/shm disappear when ssh session closes
When staging temporary files in /dev/shm via scp in one ssh session, then connecting again in a new session to access them, the files have disappeared. The /dev/shm directory itself persists and remains writable, but all files owned by that user are gone. This occurs immediately when the first ssh connection closes, before any subsequent session is opened.
systemd's logind service with RemoveIPC enabled (default on Debian/Ubuntu) clears all IPC resources owned by a user when their last session terminates. This includes files in /dev/shm, even though /dev/shm itself is a persistent tmpfs mount. The RemoveIPC directive is a security/cleanup feature but has the side effect of deleting user-staged files in /dev/shm on session exit. Workaround: stage and execute scripts in a single ssh session without closing the connection in between. Alternatively, copy staged files to a path owned by root or another account before the user session ends, since RemoveIPC only affects the invoking user's resources. Verify RemoveIPC status with systemctl show-environment | grep RemoveIPC or check /etc/systemd/logind.conf and /etc/systemd/logind.conf.d/.