Короче говоря, я работаю над «EdgeMax Feature Wizard», который является своего рода плагин-системой на маршрутизаторах Ubiquiti. Этот мастер должен иметь возможность SSH подключаться к локальным подключенным устройствам с учетными данными по умолчанию, загружать файл конфигурации и выполнять команду. Для этого мне нужно иметь возможность использовать SSH неинтерактивно из PHP (или, может быть, Bash). По сути, это несколько ограниченная и настраиваемая Debian (wheezy) mipsel-система.
Сначала я попробовал PHP Функции SSH2 но потом я заметил, что они не доступны и не скомпилированы по умолчанию: FastCGI-stderr: PHP Fatal error: Uncaught Error: Call to undefined function ssh2_connect
Вторая попытка была с phpseclib, самый рекомендуемые как я мог найти. Но в wizard-приложении я получаю ошибку: unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: unix:/var/run/php5/php.socket-0
response not received, request sent: 883 on socket: unix:/var/run/php5/php.socket-0 for /webstatus/ajax.php
и с файлом test.php, запустив только данный пример phpseclib, я получаю Segmentation fault
, К счастью, я мог вручную установить strace и получить эту трассировку, но это кажется технически слишком глубоким для меня, чтобы понять, что не так:
root@ubnt:/config/user-data/webstatus/phpseclib1.0.5# strace php-cgi test.php
execve("/usr/bin/php-cgi", ["php-cgi", "test.php"], [/* 45 vars */]) = 0
brk(0) = 0x108a000
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x774f2000
uname({sys="Linux", node="ubnt", ...}) = 0
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) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=15700, ...}) = 0
old_mmap(NULL, 15700, PROT_READ, MAP_PRIVATE, 3, 0) = 0x774cc000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libcrypt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\220\10\0\0004\0\0\0"..., 512) = 512
lseek(3, 680, SEEK_SET) = 680
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0\32\0\0\0", 32) = 32
fstat64(3, {st_mode=S_IFREG|0644, st_size=39804, ...}) = 0
old_mmap(NULL, 262652, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7748a000
mprotect(0x77493000, 61440, PROT_NONE) = 0
old_mmap(0x774a2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8000) = 0x774a2000
old_mmap(0x774a4000, 156156, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x774a4000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\260\v\0\0004\0\0\0"..., 512) = 512
lseek(3, 704, SEEK_SET) = 704
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0\32\0\0\0", 32) = 32
fstat64(3, {st_mode=S_IFREG|0644, st_size=10696, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x774cb000
old_mmap(NULL, 73968, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x77476000
mprotect(0x77478000, 61440, PROT_NONE) = 0
old_mmap(0x77487000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x77487000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libpng12.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\260,\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=160856, ...}) = 0
old_mmap(NULL, 214304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x77440000
mprotect(0x77464000, 61440, PROT_NONE) = 0
old_mmap(0x77473000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x23000) = 0x77473000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libz.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\240\25\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=95552, ...}) = 0
old_mmap(NULL, 156016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x77418000
mprotect(0x7742e000, 61440, PROT_NONE) = 0
old_mmap(0x7743d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7743d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/mipsel-linux-gnu/libjpeg.so.62", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0`\36\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=148924, ...}) = 0
old_mmap(NULL, 204016, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x773e6000
mprotect(0x77408000, 61440, PROT_NONE) = 0
old_mmap(0x77417000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x21000) = 0x77417000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/mipsel-linux-gnu/libcrypto.so.1.0.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@`\3\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1879176, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77489000
old_mmap(NULL, 1812528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7722a000
mprotect(0x773bc000, 65536, PROT_NONE) = 0
old_mmap(0x773cc000, 90112, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x192000) = 0x773cc000
old_mmap(0x773e2000, 10288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x773e2000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/mipsel-linux-gnu/libssl.so.1.0.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0 \232\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=360788, ...}) = 0
old_mmap(NULL, 406800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x771c6000
mprotect(0x77215000, 61440, PROT_NONE) = 0
old_mmap(0x77224000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4e000) = 0x77224000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\3201\0\0004\0\0\0"..., 512) = 512
lseek(3, 680, SEEK_SET) = 680
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0\32\0\0\0", 32) = 32
fstat64(3, {st_mode=S_IFREG|0644, st_size=521156, ...}) = 0
old_mmap(NULL, 574352, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x77138000
mprotect(0x771b4000, 61440, PROT_NONE) = 0
old_mmap(0x771c3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7b000) = 0x771c3000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/librt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0P\30\0\0004\0\0\0"..., 512) = 512
lseek(3, 744, SEEK_SET) = 744
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0\32\0\0\0", 32) = 32
fstat64(3, {st_mode=S_IFREG|0644, st_size=33276, ...}) = 0
old_mmap(NULL, 94912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x77120000
mprotect(0x77127000, 61440, PROT_NONE) = 0
old_mmap(0x77136000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x77136000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/mipsel-linux-gnu/libxml2.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@\254\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1840792, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77475000
old_mmap(NULL, 1829620, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x76f60000
mprotect(0x77108000, 65536, PROT_NONE) = 0
old_mmap(0x77118000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a8000) = 0x77118000
old_mmap(0x7711e000, 2804, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7711e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0004\244\1\0004\0\0\0"..., 512) = 512
lseek(3, 768, SEEK_SET) = 768
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0\32\0\0\0", 32) = 32
fstat64(3, {st_mode=S_IFREG|0755, st_size=1571316, ...}) = 0
old_mmap(NULL, 1556096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x76de4000
mprotect(0x76f48000, 65536, PROT_NONE) = 0
old_mmap(0x76f58000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x164000) = 0x76f58000
old_mmap(0x76f5d000, 11904, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x76f5d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0@^\0\0004\0\0\0"..., 512) = 512
lseek(3, 744, SEEK_SET) = 744
read(3, "\4\0\0\0\20\0\0\0\1\0\0\0GNU\0\0\0\0\0\2\0\0\0\6\0\0\0\32\0\0\0", 32) = 32
fstat64(3, {st_mode=S_IFREG|0755, st_size=881432, ...}) = 0
old_mmap(NULL, 168912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x76dba000
mprotect(0x76dd1000, 61440, PROT_NONE) = 0
old_mmap(0x76de0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x76de0000
old_mmap(0x76de2000, 5072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x76de2000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/mipsel-linux-gnu/liblzma.so.5", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0p\30\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=153888, ...}) = 0
old_mmap(NULL, 209472, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x76d86000
mprotect(0x76da9000, 61440, PROT_NONE) = 0
old_mmap(0x76db8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x76db8000
close(3) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7743f000
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x773e5000
set_thread_area(0x773ec6a0) = 0
mprotect(0x76db8000, 4096, PROT_READ) = 0
mprotect(0x76de0000, 4096, PROT_READ) = 0
mprotect(0x76f58000, 12288, PROT_READ) = 0
mprotect(0x77118000, 16384, PROT_READ) = 0
mprotect(0x77136000, 4096, PROT_READ) = 0
mprotect(0x771c3000, 4096, PROT_READ) = 0
mprotect(0x77224000, 8192, PROT_READ) = 0
mprotect(0x773cc000, 53248, PROT_READ) = 0
mprotect(0x7743d000, 4096, PROT_READ) = 0
mprotect(0x77473000, 4096, PROT_READ) = 0
mprotect(0x77487000, 4096, PROT_READ) = 0
mprotect(0x774a2000, 4096, PROT_READ) = 0
mprotect(0x774f0000, 4096, PROT_READ) = 0
munmap(0x774cc000, 15700) = 0
set_tid_address(0x773e5278) = 1701
SYS_4309() = 0
futex(0x7f9c6318, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 0) = -1 EINVAL (Invalid argument)
rt_sigaction(SIGRT_0, {0x8, [], SA_RESTART|SA_INTERRUPT|SA_NODEFER|SA_SIGINFO|SA_NOCLDWAIT|0x6daf990}, NULL, 16) = 0
rt_sigaction(SIGRT_1, {0x10000008, [], SA_RESTART|SA_INTERRUPT|SA_NODEFER|SA_NOCLDWAIT|0x6daf860}, NULL, 16) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_0 RT_1], NULL, 16) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
rt_sigaction(SIGPIPE, {0x10000000, [RT_75 RT_78 RT_79 RT_83 RT_84 RT_85 RT_88 RT_89 RT_90 RT_91 RT_92 RT_93 RT_94], SA_NOCLDSTOP}, {SIG_DFL, [RT_67 RT_69 RT_71 RT_73 RT_74 RT_78 RT_80 RT_81 RT_83 RT_84 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94], 0}, 16) = 0
brk(0) = 0x108a000
brk(0x10ab000) = 0x10ab000
getpeername(0, 0x7f9c5eb0, [112]) = -1 ENOTSOCK (Socket operation on non-socket)
old_mmap(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76b86000
munmap(0x76b86000, 2097152) = 0
old_mmap(NULL, 4190208, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76987000
munmap(0x76987000, 495616) = 0
munmap(0x76c00000, 1597440) = 0
madvise(0x76a00000, 2097152, 0xe /* MADV_??? */) = -1 EINVAL (Invalid argument)
getcwd("/config/user-data/webstatus/phpseclib1.0.5", 4096) = 43
open("/etc/localtime", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2211, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=2211, ...}) = 0
old_mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76d76000
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\0\0\0\6\0\0\0\0"..., 1024) = 1024
_llseek(3, 1159, [2183], SEEK_CUR) = 0
read(3, "\nCET-1CEST,M3.5.0,M10.5.0/3\n", 1024) = 28
close(3) = 0
munmap(0x76d76000, 65536) = 0
lstat("/usr/sbin/php-cgi", 0x7f9c2b30) = -1 ENOENT (No such file or directory)
lstat("/usr/bin/php-cgi", {st_mode=S_IFREG|0755, st_size=6598124, ...}) = 0
lstat("/usr/bin", {st_mode=S_IFDIR|0755, st_size=296, ...}) = 0
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=416, ...}) = 0
access("/usr/bin/php-cgi", X_OK) = 0
stat("/usr/bin/php-cgi", {st_mode=S_IFREG|0755, st_size=6598124, ...}) = 0
open("./php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/bin/php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/php5/cgi/php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/php5/cgi/php.ini", O_RDONLY) = 3
ioctl(3, TIOCNXCL, 0x7f9c3a00) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(3, {st_mode=S_IFREG|0644, st_size=1219, ...}) = 0
old_mmap(NULL, 1251, PROT_READ, MAP_PRIVATE, 3, 0) = 0x774ce000
fstat64(3, {st_mode=S_IFREG|0644, st_size=1219, ...}) = 0
old_mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76d76000
_llseek(3, 0, [0], SEEK_CUR) = 0
munmap(0x774ce000, 1251) = 0
close(3) = 0
munmap(0x76d76000, 65536) = 0
open("/etc/php5/cgi/conf.d", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
getdents(3, /* 2 entries */, 32768) = 32
getdents(3, /* 0 entries */, 32768) = 0
close(3) = 0
old_mmap(NULL, 163840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76d5e000
brk(0x10cc000) = 0x10cc000
futex(0x774880c4, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("/usr/lib/php/20151012/opcache.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0\0+\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=207324, ...}) = 0
old_mmap(NULL, 237176, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x76d24000
old_mmap(0x76d54000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x30000) = 0x76d54000
old_mmap(0x76d55000, 36472, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x76d55000
close(3) = 0
brk(0x10ed000) = 0x10ed000
futex(0x7711e938, FUTEX_WAKE_PRIVATE, 2147483647) = 0
time(NULL) = 1478818122
brk(0x110e000) = 0x110e000
brk(0x112f000) = 0x112f000
brk(0x1150000) = 0x1150000
brk(0x117b000) = 0x117b000
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
gettimeofday({1478818122, 106679}, NULL) = 0
open("/tmp/.ZendSem.JCb4oj", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
fchmod(3, 0666) = 0
fcntl64(3, F_GETFD) = 0
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
unlink("/tmp/.ZendSem.JCb4oj") = 0
old_mmap(NULL, 20971520, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0x75600000
fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
time(NULL) = 1478818122
fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
gettimeofday({1478818122, 142530}, NULL) = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={30, 0}}, NULL) = 0
rt_sigaction(SIGPROF, {0x10000000, [], SA_SIGINFO|0x788390}, {SIG_DFL, [RT_67 RT_69 RT_71 RT_73 RT_74 RT_78 RT_80 RT_81 RT_83 RT_84 RT_87 RT_89 RT_90 RT_91 RT_93 RT_94], 0}, 16) = 0
rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 16) = 0
old_mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76d14000
getcwd("/config/user-data/webstatus/phpseclib1.0.5", 4096) = 43
fcntl64(3, F_SETLK, {type=F_RDLCK, whence=SEEK_SET, start=1, len=1}) = 0
fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
getcwd("/config/user-data/webstatus/phpseclib1.0.5", 4096) = 43
time(NULL) = 1478818122
lstat("/config/user-data/webstatus/phpseclib1.0.5/./test.php", {st_mode=S_IFREG|0644, st_size=196, ...}) = 0
lstat("/config/user-data/webstatus/phpseclib1.0.5", {st_mode=S_IFDIR|0777, st_size=624, ...}) = 0
lstat("/config/user-data/webstatus", {st_mode=S_IFDIR|S_ISGID|0755, st_size=880, ...}) = 0
lstat("/config/user-data", {st_mode=S_IFDIR|S_ISGID|0775, st_size=1336, ...}) = 0
lstat("/config", {st_mode=S_IFDIR|S_ISGID|0775, st_size=432, ...}) = 0
getcwd("/config/user-data/webstatus/phpseclib1.0.5", 4096) = 43
time(NULL) = 1478818122
open("/config/user-data/webstatus/phpseclib1.0.5/test.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=196, ...}) = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=196, ...}) = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=196, ...}) = 0
old_mmap(NULL, 196, PROT_READ, MAP_SHARED, 4, 0) = 0x774ce000
getcwd("/config/user-data/webstatus/phpseclib1.0.5", 4095) = 43
stat("/config/user-data/webstatus/phpseclib1.0.5/test.php", {st_mode=S_IFREG|0644, st_size=196, ...}) = 0
fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
munmap(0x774ce000, 196) = 0
close(4) = 0
getcwd("/config/user-data/webstatus/phpseclib1.0.5", 4096) = 43
time(NULL) = 1478818122
lstat("/config/user-data/webstatus/phpseclib1.0.5/./Net/SSH2.php", {st_mode=S_IFREG|0777, st_size=146963, ...}) = 0
lstat("/config/user-data/webstatus/phpseclib1.0.5/./Net", {st_mode=S_IFDIR|0777, st_size=504, ...}) = 0
open("/config/user-data/webstatus/phpseclib1.0.5/Net/SSH2.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0777, st_size=146963, ...}) = 0
fstat(4, {st_mode=S_IFREG|0777, st_size=146963, ...}) = 0
fstat(4, {st_mode=S_IFREG|0777, st_size=146963, ...}) = 0
old_mmap(NULL, 146963, PROT_READ, MAP_SHARED, 4, 0) = 0x76cf0000
stat("/config/user-data/webstatus/phpseclib1.0.5/Net/SSH2.php", {st_mode=S_IFREG|0777, st_size=146963, ...}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault
Моя последняя ставка была бы вызовом exec () в PHP для простого запуска команды ssh, я просто не мог найти способ предоставить пароль по умолчанию. (Аутентификация ключа здесь не является разумной, поскольку она использует ssh для устройства с заводскими установками, и вам сначала нужно загрузить ключ.)
/usr/bin/ssh -o StrictHostKeyChecking=no -obatchmode=yes -oauthpassword.allowfromcommandline=yes --password=ubnt [email protected] /usr/bin/uptime
но кажется, что эта версия ssh не поддерживает это:
command-line: line 0: Bad configuration option: authpassword.allowfromcommandline
,
Есть другие идеи?
С точки зрения безопасности, возможно, не рекомендуется, но, поскольку общедоступные учетные данные для устройств с заводскими установками общеизвестны, я думаю, это нормально.
С помощью sshpass
что я также вручную установил через dpkg, я запускаю следующий скрипт bash:
#!/bin/bash
# for debian/wheezy sshpass 1.05 required! (1.06 requires a more recent libc6)
export SSHPASS="ubnt"sshpass -e ssh -q -o StrictHostKeyChecking=no [email protected] uptime
Других решений пока нет …