0

I tried to compile sshd from source and replace it with Ubuntu 1604's default sshd.

Grabbing source and compiling was no problem.

apt source openssh-server
cd openssh-7.2p2
./configure
make
sudo make install

My Ubuntu 1604's default sshd path is /usr/sbin/sshd but make install script will install it to /usr/local/sbin/sshd . So all these commands

service ssh start
/etc/init.d/ssh start
/bin/systemctl --no-pager start ssh.service

still points to /usr/sbin/sshd. So I edited /etc/init.d/ssh and /lib/systemd/system/ssh.service to point /usr/local/sbin/sshd .

So here's the problem I encountered. Running /usr/local/sbin/sshd works fine. But /etc/init.d/ssh start or service ssh start hangs. When I run with init.d or service, ssh login works fine but only console that starts the service hangs.

Here's system status log. It shows that the status is activating. What should I do to fix this problem?

$ service ssh status
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: activating (start) since Thu 2018-02-22 05:57:02 EST; 7s ago
 Main PID: 29491 (sshd)
    Tasks: 5
   Memory: 3.8M
      CPU: 6ms
   CGroup: /system.slice/ssh.service
           ├─29446 sshd: user [priv] 
           ├─29448 sshd: user@pts/0  
           ├─29449 -bash
           ├─29461 sudo su
           └─29491 /sbin/sshd -D

Feb 22 05:57:02 server-1604 systemd[1]: Starting OpenBSD Secure Shell server...
Feb 22 05:57:02 server-1604 sshd[29491]: Server listening on 0.0.0.0 port 22.
Feb 22 05:57:02 server-1604 sshd[29491]: Server listening on :: port 22.

FYI, this is strace log. From this, I could see that it hangs from ppoll, waiting for poll.

execve("/bin/systemctl", ["/bin/systemctl", "--no-pager", "start", "ssh.service"], [/* 23 vars */]) = 0 
brk(NULL)                               = 0x561261d0b000 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory) 
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 
fstat(3, {st_mode=S_IFREG|0644, st_size=99010, ...}) = 0 
mmap(NULL, 99010, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fdf0240f000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260Z\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=130224, ...}) = 0 
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf0240e000 
mmap(NULL, 2234080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf01fe1000 
mprotect(0x7fdf02000000, 2093056, PROT_NONE) = 0 
mmap(0x7fdf021ff000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e000) = 0x7fdf021ff000 
mmap(0x7fdf02201000, 5856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fdf02201000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0!\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=31712, ...}) = 0 
mmap(NULL, 2128832, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf01dd9000 
mprotect(0x7fdf01de0000, 2093056, PROT_NONE) = 0 
mmap(0x7fdf01fdf000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fdf01fdf000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320 \0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=137400, ...}) = 0 
mmap(NULL, 2232456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf01bb7000 
mprotect(0x7fdf01bd8000, 2093056, PROT_NONE) = 0 
mmap(0x7fdf01dd7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x20000) = 0x7fdf01dd7000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\215\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=919168, ...}) = 0 
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf0240d000 
mmap(NULL, 3015360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf018d6000 
mprotect(0x7fdf019ae000, 2093056, PROT_NONE) = 0 
mmap(0x7fdf01bad000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd7000) = 0x7fdf01bad000 
mmap(0x7fdf01bb6000, 704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fdf01bb6000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260`\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0755, st_size=138696, ...}) = 0 
mmap(NULL, 2212904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf016b9000 
mprotect(0x7fdf016d1000, 2093056, PROT_NONE) = 0 
mmap(0x7fdf018d0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7fdf018d0000 
mmap(0x7fdf018d2000, 13352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fdf018d2000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0 
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf012ef000 
mprotect(0x7fdf014af000, 2097152, PROT_NONE) = 0 
mmap(0x7fdf016af000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7fdf016af000 
mmap(0x7fdf016b5000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fdf016b5000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\25\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=456632, ...}) = 0 
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf0240c000 
mmap(NULL, 2552072, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf0107f000 
mprotect(0x7fdf010ed000, 2097152, PROT_NONE) = 0 
mmap(0x7fdf012ed000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6e000) = 0x7fdf012ed000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\r\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=14608, ...}) = 0 
mmap(NULL, 2109680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf00e7b000 
mprotect(0x7fdf00e7e000, 2093056, PROT_NONE) = 0 
mmap(0x7fdf0107d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fdf0107d000 
close(3)                                = 0 
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory) 
open("/lib/x86_64-linux-gnu/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = 3 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320(\0\0\0\0\0\0"..., 832) = 832 
fstat(3, {st_mode=S_IFREG|0644, st_size=80496, ...}) = 0 
mmap(NULL, 2175544, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fdf00c67000 
mprotect(0x7fdf00c79000, 2097152, PROT_NONE) = 0 
mmap(0x7fdf00e79000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7fdf00e79000 
close(3)                                = 0 
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf0240b000 
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf0240a000 
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fdf02408000 
arch_prctl(ARCH_SET_FS, 0x7fdf02408880) = 0 
mprotect(0x7fdf016af000, 16384, PROT_READ) = 0 
mprotect(0x7fdf00e79000, 4096, PROT_READ) = 0 
mprotect(0x7fdf0107d000, 4096, PROT_READ) = 0 
mprotect(0x7fdf018d0000, 4096, PROT_READ) = 0 
mprotect(0x7fdf012ed000, 4096, PROT_READ) = 0 
mprotect(0x7fdf01bad000, 4096, PROT_READ) = 0 
mprotect(0x7fdf01dd7000, 4096, PROT_READ) = 0 
mprotect(0x7fdf01fdf000, 4096, PROT_READ) = 0 
mprotect(0x7fdf021ff000, 4096, PROT_READ) = 0 
mprotect(0x561260c29000, 20480, PROT_READ) = 0 
mprotect(0x7fdf02428000, 4096, PROT_READ) = 0 
munmap(0x7fdf0240f000, 99010)           = 0 
set_tid_address(0x7fdf02408b50)         = 22447 
set_robust_list(0x7fdf02408b60, 24)     = 0 
rt_sigaction(SIGRTMIN, {0x7fdf016beb50, [], SA_RESTORER|SA_SIGINFO, 0x7fdf016ca390}, NULL, 8) = 0 
rt_sigaction(SIGRT_1, {0x7fdf016bebe0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7fdf016ca390}, NULL, 8) = 0 
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0 
brk(NULL)                               = 0x561261d0b000 
brk(0x561261d2c000)                     = 0x561261d2c000 
statfs("/sys/fs/selinux", 0x7ffd83e19130) = -1 ENOENT (No such file or directory) 
statfs("/selinux", 0x7ffd83e19130)      = -1 ENOENT (No such file or directory) 
open("/proc/filesystems", O_RDONLY)     = 3 
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tr"..., 1024) = 375 
read(3, "", 1024)                       = 0 
close(3)                                = 0 
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3 
fstat(3, {st_mode=S_IFREG|0644, st_size=2981280, ...}) = 0 
mmap(NULL, 2981280, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fdf0098f000 
close(3)                                = 0 
open("/proc/self/stat", O_RDONLY|O_CLOEXEC) = 3 
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 
read(3, "22447 (systemctl) R 22445 22445 "..., 1024) = 345 
close(3)                                = 0 
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 
stat("/proc/1/root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 
stat("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0 
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fdf02408b50) = 22448 
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 
geteuid()                               = 0 
geteuid()                               = 0 
open("/sys/fs/kdbus/0-system/bus", O_RDWR|O_NOCTTY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3 
getsockopt(3, SOL_SOCKET, SO_RCVBUF, [212992], [4]) = 0 
setsockopt(3, SOL_SOCKET, SO_RCVBUFFORCE, [8388608], 4) = 0 
getsockopt(3, SOL_SOCKET, SO_SNDBUF, [212992], [4]) = 0 
setsockopt(3, SOL_SOCKET, SO_SNDBUFFORCE, [8388608], 4) = 0 
connect(3, {sa_family=AF_LOCAL, sun_path="/run/systemd/private"}, 22) = 0 
getsockopt(3, SOL_SOCKET, SO_PEERCRED, {pid=1, uid=0, gid=0}, [12]) = 0 
fstat(3, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0 
getsockopt(3, SOL_SOCKET, SO_ACCEPTCONN, [0], [4]) = 0 
getsockname(3, {sa_family=AF_LOCAL, NULL}, [2]) = 0 
geteuid()                               = 0 
sendmsg(3, {msg_name(0)=NULL, msg_iov(3)=[{"\0AUTH EXTERNAL ", 15}, {"30", 2}, {"\r\nNEGOTIATE_UNIX_FD\r\nBEGIN\r\n", 28}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 45 
getsockopt(3, SOL_SOCKET, SO_PEERCRED, {pid=1, uid=0, gid=0}, [12]) = 0 
gettid()                                = 22447 
getrandom("\222\221\275\305nfnD\315\370l\37~}\30\332", 16, GRND_NONBLOCK) = 16 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"OK ccc4da2994f3465e8c1b1fc719cf6"..., 256}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 52 
sendmsg(3, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\4\1\34\0\0\0\1\0\0\0\240\0\0\0\1\1o\0\31\0\0\0/org/fre"..., 176}, {"\v\0\0\0ssh.service\0\7\0\0\0replace\0", 28}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 204 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\1(\0\0\0\1\0\0\0\17\0\0\0\5\1u\0\1\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\10\1g\0\1o\0\0#\0\0\0/org/freedesktop/sys"..., 48}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 48 
sendmsg(3, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\4\1\20\0\0\0\2\0\0\0\227\0\0\0\1\1o\0\31\0\0\0/org/fre"..., 168}, {"\v\0\0\0ssh.service\0", 16}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 184 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1H\0\0\0\2\0\0\0\206\0\0\0\1\1o\0#\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/systemd1/job/38"..., 200}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 200 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\0011\0\0\0\3\0\0\0\17\0\0\0\5\1u\0\2\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\10\1g\0\1o\0\0,\0\0\0/org/freedesktop/sys"..., 57}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 57 
sendmsg(3, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\4\0019\0\0\0\3\0\0\0\240\0\0\0\1\1o\0,\0\0\0/org/fre"..., 176}, {"\35\0\0\0org.freedesktop.systemd1.Uni"..., 57}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 233 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\1\10\0\0\0\4\0\0\0\17\0\0\0\5\1u\0\3\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24 
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\10\1g\0\1v\0\0\1b\0\0\0\0\0\0", 16}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 16 
recvmsg(3, 0x7ffd83e17d70, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable) 
ppoll([{fd=3, events=POLLIN}], 1, NULL, NULL, 8strace: Process 22447 detached 
 <detached ... >
  • Maybe you should see what options are passed to configure in debian/rules. – muru Feb 26 '18 at 14:30
  • @muru Thanks. I found that it was related to systemd configuration, related post here unix.stackexchange.com/questions/313080/… – Kang Feb 28 '18 at 8:19
  • @muru and it was setup by debian/rules. Thanks for help! – Kang Feb 28 '18 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.