Mosh/tmux/screen broken in NixOS 18.04
Issue description
On the current NixOS master I am only able to log on with mosh via the root user. This is true both from remote machines connecting to the NixOS server and from the same machine.
Mosh works as expected in NixOS 17.09. In trying to isolate the issue I backported the Mosh version from the master to 17.09 and it worked fine there. I'm not sure how to proceed.
Steps to reproduce
configuration.nix:
programs.mosh.enable = true
Mosh works as expected and the following log is produced only when logging on as root:
$ mosh root@localhost
Mar 03 14:36:06 nixos sshd[24460]: Connection from 127.0.0.1 port 47512 on 127.0.0.1 port 22
Mar 03 14:36:06 nixos sshd[24460]: Postponed keyboard-interactive for root from 127.0.0.1 port 47512 ssh2 [preauth]
Mar 03 14:36:07 nixos sshd[24460]: Postponed keyboard-interactive/pam for root from 127.0.0.1 port 47512 ssh2 [preauth]
Mar 03 14:36:07 nixos sshd[24460]: Accepted keyboard-interactive/pam for root from 127.0.0.1 port 47512 ssh2
Mar 03 14:36:07 nixos sshd[24460]: pam_unix(sshd:session): session opened for user root by (uid=0)
Mar 03 14:36:07 nixos systemd[1]: Started Session 17 of user root.
Mar 03 14:36:07 nixos systemd-logind[1126]: New session 17 of user root.
Mar 03 14:36:07 nixos sshd[24460]: Starting session: command on pts/0 for root from 127.0.0.1 port 47512 id 0
Mar 03 14:36:07 nixos sshd[24460]: Received disconnect from 127.0.0.1 port 47512:11: disconnected by user
Mar 03 14:36:07 nixos sshd[24460]: Disconnected from user root 127.0.0.1 port 47512
Mar 03 14:36:07 nixos sshd[24460]: pam_unix(sshd:session): session closed for user root
Mosh never connects and the mosh process is not running when logging on with a normal user:
$ mosh guest@localhost
mosh: Nothing received from server on UDP port 60001. (9 s without contact.) [To quit: Ctrl-^ .]
Mar 03 14:30:15 nixos sshd[7717]: Connection from 127.0.0.1 port 47480 on 127.0.0.1 port 22
Mar 03 14:30:15 nixos sshd[7717]: Postponed keyboard-interactive for guest from 127.0.0.1 port 47480 ssh2 [preauth]
Mar 03 14:30:16 nixos sshd[7717]: Postponed keyboard-interactive/pam for guest from 127.0.0.1 port 47480 ssh2 [preauth]
Mar 03 14:30:16 nixos sshd[7717]: Accepted keyboard-interactive/pam for guest from 127.0.0.1 port 47480 ssh2
Mar 03 14:30:16 nixos sshd[7717]: pam_unix(sshd:session): session opened for user guest by (uid=0)
Mar 03 14:30:16 nixos systemd-logind[1126]: New session 6 of user guest.
Mar 03 14:30:16 nixos systemd[1]: Created slice User Slice of guest.
Mar 03 14:30:16 nixos systemd[1]: Starting User Manager for UID 1000...
Mar 03 14:30:16 nixos systemd[1]: Started Session 6 of user guest.
Mar 03 14:30:16 nixos systemd[7721]: pam_unix(systemd-user:session): session opened for user guest by (uid=0)
Mar 03 14:30:16 nixos systemd[7721]: Reached target Paths.
Mar 03 14:30:16 nixos systemd[7721]: Reached target Timers.
Mar 03 14:30:16 nixos systemd[7721]: Reached target Sockets.
Mar 03 14:30:16 nixos systemd[7721]: Reached target Basic System.
Mar 03 14:30:16 nixos systemd[1]: Started User Manager for UID 1000.
Mar 03 14:30:16 nixos sshd[7717]: User child is on pid 7727
Mar 03 14:30:16 nixos systemd[7721]: Starting SSH Agent...
Mar 03 14:30:16 nixos systemd[7721]: Started SSH Agent.
Mar 03 14:30:16 nixos systemd[7721]: Reached target Default.
Mar 03 14:30:16 nixos systemd[7721]: Startup finished in 22ms.
Mar 03 14:30:16 nixos sshd[7727]: Starting session: command on pts/2 for guest from 127.0.0.1 port 47480 id 0
Mar 03 14:30:16 nixos sshd[7727]: Received disconnect from 127.0.0.1 port 47480:11: disconnected by user
Mar 03 14:30:16 nixos sshd[7727]: Disconnected from user guest 127.0.0.1 port 47480
Mar 03 14:30:16 nixos sshd[7717]: pam_unix(sshd:session): session closed for user guest
Mar 03 14:30:16 nixos systemd[1]: session-6.scope: Killing process 7717 (sshd) with signal SIGTERM.
Mar 03 14:30:16 nixos systemd[1]: session-6.scope: Killing process 7727 (sshd) with signal SIGTERM.
Mar 03 14:30:16 nixos systemd[1]: session-6.scope: Killing process 7745 (mosh-server) with signal SIGTERM.
Mar 03 14:30:16 nixos systemd[1]: Stopping Session 6 of user guest.
Mar 03 14:30:16 nixos systemd[1]: Stopped Session 6 of user guest.
Mar 03 14:30:16 nixos systemd-logind[1126]: Removed session 6.
Mar 03 14:30:16 nixos systemd[1]: Stopping User Manager for UID 1000...
Mar 03 14:30:16 nixos systemd[7721]: Stopped target Default.
Mar 03 14:30:16 nixos systemd[7721]: Stopping SSH Agent...
Mar 03 14:30:16 nixos systemd[7721]: Stopped SSH Agent.
Mar 03 14:30:16 nixos systemd[7721]: Stopped target Basic System.
Mar 03 14:30:16 nixos systemd[7721]: Stopped target Timers.
Mar 03 14:30:16 nixos systemd[7721]: Stopped target Paths.
Mar 03 14:30:16 nixos systemd[7721]: Stopped target Sockets.
Mar 03 14:30:16 nixos systemd[7721]: Reached target Shutdown.
Mar 03 14:30:16 nixos systemd[7721]: Starting Exit the Session...
Mar 03 14:30:16 nixos systemd[7721]: Received SIGRTMIN+24 from PID 7746 (/nix/store/cb3s).
Mar 03 14:30:16 nixos systemd[1]: [email protected]: Killing process 7746 (/nix/store/cb3s) with signal SIGKILL.
Mar 03 14:30:16 nixos systemd[1]: Stopped User Manager for UID 1000.
Mar 03 14:30:16 nixos systemd[1]: Removed slice User Slice of guest.
Technical details
- system:
"x86_64-linux" - host os:
Linux 4.14.20, NixOS, 18.03.git.831ef47 (Impala) - multi-user?:
no - sandbox:
yes - version:
nix-env (Nix) 1.11.16 - channels(root):
"unstable-18.03pre127921.9b25b9347d9, nixos-17.09.3008.c831224528c" - nixpkgs:
/root/nixpkgs
To troubleshoot further, as the user guest run: mosh-server. You should see an output similar to:
MOSH CONNECT 60004 4NeCCgvZFe2RnPgrcU1PQw
mosh-server (mosh 1.3.2)
Copyright 2012 Keith Winstein <[email protected]>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[mosh-server detached, pid = 30261]
Using the above as an example, then run MOSH_KEY=4NeCCgvZFe2RnPgrcU1PQw mosh-client localhost 60004. Essentially, you'd be by-passing the SSH-based setup procedure.
Thanks for the suggestion. Mosh mosh works when performing those steps. However when closing the last terminal of the user owning mosh-server, the Mosh process is killed. On NixOS 17.09 it kept running.
It's not just Mosh. screen and tmux are broken in the same way. It seems it's really the issue which PR #16021 fixed that is back. KillUserProcesses is still set to "no" however.
$ ssh [email protected]
Password:
Last login: Sun Oct 8 14:28:12 2017 from 192.168.190.1
Mar 03 18:16:56 nixos sshd[3292]: Connection from 192.168.190.1 port 31780 on 192.168.190.128 port 22
Mar 03 18:17:01 nixos sshd[3292]: Postponed keyboard-interactive/pam for guest from 192.168.190.1 port 31780 ssh2 [preauth]
Mar 03 18:17:01 nixos sshd[3292]: Accepted keyboard-interactive/pam for guest from 192.168.190.1 port 31780 ssh2
Mar 03 18:17:01 nixos sshd[3292]: pam_unix(sshd:session): session opened for user guest by (uid=0)
Mar 03 18:17:01 nixos systemd-logind[1149]: New session 3 of user guest.
Mar 03 18:17:01 nixos systemd[1]: Created slice User Slice of guest.
Mar 03 18:17:01 nixos systemd[1]: Starting User Manager for UID 1000...
Mar 03 18:17:01 nixos systemd[1]: Started Session 3 of user guest.
Mar 03 18:17:01 nixos systemd[3397]: pam_unix(systemd-user:session): session opened for user guest by (uid=0)
Mar 03 18:17:01 nixos systemd[3397]: Reached target Timers.
Mar 03 18:17:01 nixos systemd[3397]: Reached target Sockets.
Mar 03 18:17:01 nixos sshd[3292]: User child is on pid 3402
Mar 03 18:17:01 nixos systemd[3397]: Reached target Paths.
Mar 03 18:17:01 nixos sshd[3402]: Starting session: shell on pts/2 for guest from 192.168.190.1 port 31780 id 0
Mar 03 18:17:01 nixos systemd[3397]: Reached target Basic System.
Mar 03 18:17:01 nixos systemd[1]: Started User Manager for UID 1000.
Mar 03 18:17:01 nixos systemd[3397]: Starting SSH Agent...
Mar 03 18:17:01 nixos systemd[3397]: Started SSH Agent.
Mar 03 18:17:01 nixos systemd[3397]: Reached target Default.
Mar 03 18:17:01 nixos systemd[3397]: Startup finished in 21ms.
[guest@nixos:~]$ screen
$ top
[detached from 3603.pts-2.nixos]
[guest@nixos:~]$ exit
logout
Connection to 192.168.190.128 closed.
Mar 03 18:17:12 nixos sshd[3402]: Close session: user guest from 192.168.190.1 port 31780 id 0
Mar 03 18:17:12 nixos sshd[3402]: Received disconnect from 192.168.190.1 port 31780:11: disconnected by user
Mar 03 18:17:12 nixos sshd[3402]: Disconnected from user guest 192.168.190.1 port 31780
Mar 03 18:17:12 nixos sshd[3292]: pam_unix(sshd:session): session closed for user guest
Mar 03 18:17:12 nixos systemd[1]: session-3.scope: Killing process 3292 (sshd) with signal SIGTERM.
Mar 03 18:17:12 nixos systemd[1]: session-3.scope: Killing process 3603 (screen) with signal SIGTERM.
Mar 03 18:17:12 nixos systemd[1]: session-3.scope: Killing process 3604 (bash) with signal SIGTERM.
Mar 03 18:17:12 nixos systemd[1]: session-3.scope: Killing process 3638 (top) with signal SIGTERM.
Mar 03 18:17:12 nixos systemd[1]: Stopping Session 3 of user guest.
Mar 03 18:17:12 nixos systemd[1]: Stopped Session 3 of user guest.
Mar 03 18:17:12 nixos systemd-logind[1149]: Removed session 3.
Mar 03 18:17:12 nixos systemd[1]: Stopping User Manager for UID 1000...
Mar 03 18:17:12 nixos systemd[3397]: Stopped target Default.
Mar 03 18:17:12 nixos systemd[3397]: Stopping SSH Agent...
Mar 03 18:17:12 nixos systemd[3397]: Stopped SSH Agent.
Mar 03 18:17:12 nixos systemd[3397]: Stopped target Basic System.
Mar 03 18:17:12 nixos systemd[3397]: Stopped target Sockets.
Mar 03 18:17:12 nixos systemd[3397]: Stopped target Paths.
Mar 03 18:17:12 nixos systemd[3397]: Reached target Shutdown.
Mar 03 18:17:12 nixos systemd[3397]: Starting Exit the Session...
Mar 03 18:17:12 nixos systemd[3397]: Stopped target Timers.
Mar 03 18:17:12 nixos systemd[3397]: Received SIGRTMIN+24 from PID 3758 (/nix/store/cb3s).
Mar 03 18:17:12 nixos systemd[1]: [email protected]: Killing process 3758 (/nix/store/cb3s) with signal SIGKILL.
Mar 03 18:17:12 nixos systemd[1]: Stopped User Manager for UID 1000.
Mar 03 18:17:12 nixos systemd[1]: Removed slice User Slice of guest.
Password:
Last login: Sat Mar 3 18:17:01 2018 from 192.168.190.1
[guest@nixos:~]$ screen -r
There is no screen to be resumed.
[guest@nixos:~]$ ps aux | grep top
guest 6716 0.0 0.0 120772 1460 pts/2 S+ 18:19 0:00 grep top
The systemd update broke this due to no longer reading configs from the right place (as I understand it).
This has been addressed, and I believe was merged recently (past 24hours?) into nixpkgs--not sure if master or staging.
Looks like master: 88530e02b6fa9b5429dc09972b599e7b0a3af569
Give that a go, or wait until it hits the channel (if it hasn't). Hope this helps!
Great, I'll update the status when I have that commit.
Just to link all the duplicates of the same systemd update issue: #35415
Indeed 88530e0 fixed the issue.