Eu tentei compilar o sshd a partir do código-fonte e substituí-lo pelo sshd padrão do Ubuntu 1604.
Agarrar a fonte e compilar não foi problema.
apt source openssh-server
cd openssh-7.2p2
./configure
make
sudo make install
O caminho sshd padrão do meu Ubuntu 1604 é /usr/sbin/sshd
, mas o script de instalação irá instalá-lo em /usr/local/sbin/sshd
. Então todos esses comandos
service ssh start
/etc/init.d/ssh start
/bin/systemctl --no-pager start ssh.service
ainda aponta para /usr/sbin/sshd
. Então eu editei /etc/init.d/ssh
e /lib/systemd/system/ssh.service
para apontar /usr/local/sbin/sshd
.
Então aqui está o problema que eu encontrei. Rodar / usr / local / sbin / sshd funciona bem. Mas /etc/init.d/ssh start
ou service ssh start
trava. Quando eu executo com init.d ou service, o ssh login funciona bem, mas apenas o console que inicia o serviço trava.
Aqui está o log de status do sistema. Isso mostra que o status é ativando . O que devo fazer para corrigir este problema?
$ 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, este é o log strace. A partir disso, pude ver que ele trava de ppoll, esperando por pesquisa.
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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%0Z%pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%%pre%!%pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%0 %pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%%pre%5%pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%0'%pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%P\t%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%00%pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%0\r%pre%%pre%%pre%%pre%%pre%%pre%"..., 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, "7ELF%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%>%pre%%pre%%pre%%pre%0(%pre%%pre%%pre%%pre%%pre%%pre%"..., 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)=[{"%pre%AUTH 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("2155nfnD50l~}2", 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%pre%%pre%%pre%%pre%%pre%%pre%0%pre%%pre%%pre%o%pre%%pre%%pre%%pre%/org/fre"..., 176}, {"\v%pre%%pre%%pre%ssh.service%pre%%pre%%pre%%pre%replace%pre%", 28}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 204
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l(%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%u%pre%%pre%%pre%%pre%", 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)=[{"g%pre%o%pre%%pre%#%pre%%pre%%pre%/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%pre%%pre%%pre%%pre%%pre%%pre%7%pre%%pre%%pre%o%pre%%pre%%pre%%pre%/org/fre"..., 168}, {"\v%pre%%pre%%pre%ssh.service%pre%", 16}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 184
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"lH%pre%%pre%%pre%%pre%%pre%%pre%6%pre%%pre%%pre%o%pre%#%pre%%pre%%pre%", 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%pre%11%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%u%pre%%pre%%pre%%pre%", 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)=[{"g%pre%o%pre%%pre%,%pre%%pre%%pre%/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%pre%19%pre%%pre%%pre%%pre%%pre%%pre%0%pre%%pre%%pre%o%pre%,%pre%%pre%%pre%/org/fre"..., 176}, {"%pre%%pre%%pre%org.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%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%%pre%u%pre%%pre%%pre%%pre%", 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)=[{"g%pre%v%pre%%pre%b%pre%%pre%%pre%%pre%%pre%%pre%", 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 ... >