How to run remote SSH commands non-interactively via Bash or PHP on limited/embedded linux systems? -
long story short, i'm working on "edgemax feature wizard" kind of plugin-system on ubiquiti's routers. wizard should able ssh local attached reseted devices default credentials, upload configuration file , issue command. need able use ssh non-interactively php (or bash maybe). limited , customized debian (wheezy) mipsel-system.
first tried php's ssh2 functions noticed not available , not compiled in default: fastcgi-stderr: php fatal error: uncaught error: call undefined function ssh2_connect
second try phpseclib, the most recommended way find. within wizard-application error: unexpected end-of-file (perhaps 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 /webstatus/ajax.php , test.php file, running given phpseclib example segmentation fault. luckily manually install strace , trace, seems go technically deep me understand, wrong:
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 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 sigsegv +++ segmentation fault my last bet exec() call in php run ssh command, couldn't find way supply default password. (key authentication isn't smart here since using ssh factory reseted device , first need upload key.) /usr/bin/ssh -o stricthostkeychecking=no -obatchmode=yes -oauthpassword.allowfromcommandline=yes --password=ubnt ubnt@192.168.1.20 /usr/bin/uptime seems version of ssh doesn't support this: command-line: line 0: bad configuration option: authpassword.allowfromcommandline.
any other ideas?
from security maybe perspective not recommended, since public known credentials factory-reseted devices, guess ok.
using sshpass manually installed via dpkg, im running following bash script:
#!/bin/bash # debian/wheezy sshpass 1.05 required! (1.06 requires more recent libc6) export sshpass="ubnt" sshpass -e ssh -q -o stricthostkeychecking=no ubnt@192.168.1.20 uptime
Comments
Post a Comment