You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your home directory on a networked filesystem (AFS, NFS, etc.) that requires authentication? Also, did you check that .viminfo didn't accidentally become owned by root (try ls -l .viminfo)?
When I ssh to the Ubuntu box, the encrypted home folder gets mounted automatically.
But when I mosh to the Ubuntu box, the encrypted home folder is not mounted automatically. If I mount it with ecryptfs-mount-private the problem goes away.
Ah, eCryptfs. What actually happens is that pam_ecryptfs maintains a session counter (/dev/shm/ecryptfs-$USER-Private) that is incremented on PAM login and decremented on PAM logout. The temporary SSH session that mosh uses to launch the remote mosh-server causes a PAM login followed immediately by a PAM logout, so the counter reaches zero and the encrypted folder is unmounted immediately.
I don’t think that running a PAM session as a non-root user is a supported operation, so mosh-server itself cannot cause a PAM login. But this is a problem we’d like to solve, even if we don’t currently have a good solution, so I’ll reopen this in case someone has ideas.
changed the title [-]I get "E138: Can't write viminfo file" error only when connected via mosh[/-][+]mosh-server does not keep eCryptfs home directory mounted (needs PAM session?)[/+]on May 26, 2014
(As an example of the kind of amazing horrible things that go spectacularly wrong if you try to run a PAM session as non-root, I just filed LP #1323421 “pam_ecryptfs returns twice from fork in error conditions”.)
This is with a totally empty but existing.profile, both in the encrypted and the unencrypted home-folder on remote. Why does the counter add one when disconnecting and subtract one when connecting?
That’s not what’s going on. ssh increments the count by 1 when opening the session, and decrements the count by 1 when closing the session. When you ran ssh remote cat /dev/shm/ecryptfs-$USER-Private, the cat ran between this increment and decrement pair. mosh uses a short-lived ssh session to create the session, which increments and then immediately decrements the count, leaving it net unchanged.
We'd still like to find a better fix for this, but tonight @eminence mentioned a half-decent workaround on #mosh: ssh localhost upon connecting to the remote host. mosh remote-host-name ssh localhost will often work as well.
This won't work all the time, but when it does you still get most of the benefits of mosh.
changed the title [-]mosh-server does not keep eCryptfs home directory mounted (needs PAM session?)[/-][+]mosh interacts poorly with PAM[/+]on Jan 20, 2023
Activity
andersk commentedon May 25, 2014
Is your home directory on a networked filesystem (AFS, NFS, etc.) that requires authentication? Also, did you check that .viminfo didn't accidentally become owned by root (try ls -l .viminfo)?
rhazegh commentedon May 26, 2014
No. It's on a local hard disk. The home folder is encrypted with eCryptfs.
The file is not owned by root:
-rw------- 1 my_account my_account 625 May 25 17:06 .viminfoIf the problem was file permission, I suppose the same error should have happened when I used ssh.
rhazegh commentedon May 26, 2014
I found the issue:
ecryptfs-mount-privatethe problem goes away.andersk commentedon May 26, 2014
Ah, eCryptfs. What actually happens is that pam_ecryptfs maintains a session counter (
/dev/shm/ecryptfs-$USER-Private) that is incremented on PAM login and decremented on PAM logout. The temporary SSH session thatmoshuses to launch the remotemosh-servercauses a PAM login followed immediately by a PAM logout, so the counter reaches zero and the encrypted folder is unmounted immediately.I don’t think that running a PAM session as a non-root user is a supported operation, so
mosh-serveritself cannot cause a PAM login. But this is a problem we’d like to solve, even if we don’t currently have a good solution, so I’ll reopen this in case someone has ideas.[-]I get "E138: Can't write viminfo file" error only when connected via mosh[/-][+]mosh-server does not keep eCryptfs home directory mounted (needs PAM session?)[/+]andersk commentedon May 26, 2014
(As an example of the kind of amazing horrible things that go spectacularly wrong if you try to run a PAM session as non-root, I just filed LP #1323421 “pam_ecryptfs returns twice from fork in error conditions”.)
diepes commentedon Nov 4, 2014
Prevent auto unmount by deleting ~/.ecryptfs/auto-umount
mek-apelsin commentedon Feb 28, 2015
While running mosh 1.2.4a:
local$ mosh remote
remote(encrypted)$ cat /dev/shm/ecryptfs-$USER-Private
0
remote(encrypted)$ ecryptfs-mount-private
FAIL
remote$ cat /dev/shm/ecryptfs-$USER-Private
1
remote(encrypted)$ ^D
local$ ssh remote cat /dev/shm/ecryptfs-$USER-Private
2 (WTF 1)
local$ mosh remote
remote(unencrypted)$ (WTF2)
remote$ cat /dev/shm/ecryptfs-$USER-Private
1 (WTF 3)
remote(encrypted)$ ^D
local$ ssh remote cat /dev/shm/ecryptfs-$USER-Private
2 (WTF 4)
This is with a totally empty but existing.profile, both in the encrypted and the unencrypted home-folder on remote. Why does the counter add one when disconnecting and subtract one when connecting?
andersk commentedon Mar 1, 2015
That’s not what’s going on.
sshincrements the count by 1 when opening the session, and decrements the count by 1 when closing the session. When you ranssh remote cat /dev/shm/ecryptfs-$USER-Private, thecatran between this increment and decrement pair.moshuses a short-livedsshsession to create the session, which increments and then immediately decrements the count, leaving it net unchanged.cgull commentedon Mar 31, 2016
We'd still like to find a better fix for this, but tonight @eminence mentioned a half-decent workaround on #mosh:
ssh localhostupon connecting to the remote host.mosh remote-host-name ssh localhostwill often work as well.This won't work all the time, but when it does you still get most of the benefits of mosh.
[-]mosh-server does not keep eCryptfs home directory mounted (needs PAM session?)[/-][+]mosh interacts poorly with PAM[/+]