コンテンツへスキップ

Raspberry Pi 3 B +にphp-ssh2インストール

PHPのSSH2インストール

Raspberry Piで以下のSSH2を利用するスクリプトを実行した際に、エラーが出ました。
[Sat Jul 06 17:32:35.669744 2019] [php7:error] PHP Fatal error: Uncaught Error: Call to undefined function ssh2_connect() in /var/www/

Call to undefined function ssh2_connect()とあったので、「php-ssh2」をインストールすることで、PHPでSSH2を利用できます。

$connection = ssh2_connect($target_ip);
ssh2_auth_password($connection, $target_user, $target_pass);
$stream = ssh2_exec($connection, $cmd);
$errorstream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
stream_set_blocking($stream, true);
stream_set_blocking($errorstream, true);
以下、実際の操作ログです。
Apache経由で利用する際は、apacheの再起動を実施後、利用してください。
@raspberrypi:~ $ sudo apt-cache search libss
[sudo]スワード:
cl-plus-ssl - Common Lisp interface to OpenSSL
dcmtk - OFFIS DICOM toolkit command line utilities
dlang-openssl - D version of the C headers for openssl
lib32gcc-6-dev-amd64-cross - GCC support library (32 bit development files)
lib32gcc-6-dev-mips64el-cross - GCC support library (32 bit development files)
lib32gcc-6-dev-s390x-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-amd64-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-mips64-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-mips64el-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-mips64r6-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-mips64r6el-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-ppc64-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-s390x-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-sparc64-cross - GCC support library (32 bit development files)
lib32gcc-8-dev-x32-cross - GCC support library (32 bit development files)
lib64gcc-6-dev-i386-cross - GCC support library (64bit development files)
lib64gcc-6-dev-mips-cross - GCC support library (64bit development files)
lib64gcc-6-dev-mipsel-cross - GCC support library (64bit development files)
lib64gcc-8-dev-i386-cross - GCC support library (64bit development files)
lib64gcc-8-dev-mips-cross - GCC support library (64bit development files)
lib64gcc-8-dev-mipsel-cross - GCC support library (64bit development files)
lib64gcc-8-dev-mipsr6-cross - GCC support library (64bit development files)
lib64gcc-8-dev-mipsr6el-cross - GCC support library (64bit development files)
lib64gcc-8-dev-powerpc-cross - GCC support library (64bit development files)
lib64gcc-8-dev-x32-cross - GCC support library (64bit development files)
libdcmtk-dev - OFFIS DICOM toolkit development libraries and headers
libdcmtk14 - OFFIS DICOM toolkit runtime libraries
libgcc-4.9-dev - GCC support library (development files)
libgcc-5-dev - GCC support library (development files)
libgcc-6-dev - GCC support library (development files)
libgcc-6-dev-amd64-cross - GCC support library (development files)
libgcc-6-dev-arm64-cross - GCC support library (development files)
libgcc-6-dev-armel-cross - GCC support library (development files)
libgcc-6-dev-armhf-cross - GCC support library (development files)
libgcc-6-dev-i386-cross - GCC support library (development files)
libgcc-6-dev-mips-cross - GCC support library (development files)
libgcc-6-dev-mips64el-cross - GCC support library (development files)
libgcc-6-dev-mipsel-cross - GCC support library (development files)
libgcc-6-dev-ppc64el-cross - GCC support library (development files)
libgcc-6-dev-s390x-cross - GCC support library (development files)
libgcc-7-dev - GCC support library (development files)
libgcc-8-dev - GCC support library (development files)
libgcc-8-dev-alpha-cross - GCC support library (development files)
libgcc-8-dev-amd64-cross - GCC support library (development files)
libgcc-8-dev-arm64-cross - GCC support library (development files)
libgcc-8-dev-armel-cross - GCC support library (development files)
libgcc-8-dev-armhf-cross - GCC support library (development files)
libgcc-8-dev-hppa-cross - GCC support library (development files)
libgcc-8-dev-i386-cross - GCC support library (development files)
libgcc-8-dev-m68k-cross - GCC support library (development files)
libgcc-8-dev-mips-cross - GCC support library (development files)
libgcc-8-dev-mips64-cross - GCC support library (development files)
libgcc-8-dev-mips64el-cross - GCC support library (development files)
libgcc-8-dev-mips64r6-cross - GCC support library (development files)
libgcc-8-dev-mips64r6el-cross - GCC support library (development files)
libgcc-8-dev-mipsel-cross - GCC support library (development files)
libgcc-8-dev-mipsr6-cross - GCC support library (development files)
libgcc-8-dev-mipsr6el-cross - GCC support library (development files)
libgcc-8-dev-powerpc-cross - GCC support library (development files)
libgcc-8-dev-powerpcspe-cross - GCC support library (development files)
libgcc-8-dev-ppc64-cross - GCC support library (development files)
libgcc-8-dev-ppc64el-cross - GCC support library (development files)
libgcc-8-dev-riscv64-cross - GCC support library (development files)
libgcc-8-dev-s390x-cross - GCC support library (development files)
libgcc-8-dev-sh4-cross - GCC support library (development files)
libgcc-8-dev-sparc64-cross - GCC support library (development files)
libgcc-8-dev-x32-cross - GCC support library (development files)
libn32gcc-6-dev-mips-cross - GCC support library (n32 development files)
libn32gcc-6-dev-mips64el-cross - GCC support library (n32 development files)
libn32gcc-6-dev-mipsel-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mips-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mips64-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mips64el-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mips64r6-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mips64r6el-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mipsel-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mipsr6-cross - GCC support library (n32 development files)
libn32gcc-8-dev-mipsr6el-cross - GCC support library (n32 development files)
libnet-ssh2-perl - Perl module for the SSH 2 protocol
librust-libgit2-sys+libssh2-sys-dev - Native bindings to the libgit2 library - feature "libssh2-sys"
librust-libssh2-sys-dev - Native bindings to the libssh2 library - Rust source code
libss2 - command-line interface parsing library
libss7-2.0 - Signalling System 7 (ss7) library
libss7-dev - Signalling System 7 (ss7) development files
libsscm-dev - Development library for sigscheme Scheme interpreter
libsscm3 - Shared library for sigscheme Scheme interpreter
libssh-4 - tiny C SSH library (OpenSSL flavor)
libssh-dev - tiny C SSH library - Development files (OpenSSL flavor)
libssh-doc - tiny C SSH library - Documentation files
libssh-gcrypt-4 - tiny C SSH library (gcrypt flavor)
libssh-gcrypt-dev - tiny C SSH library - Development files (gcrypt flavor)
libssh2-1 - SSH2 client-side library
libssh2-1-dev - SSH2 client-side library (development headers)
libssl-dev - Secure Sockets Layer toolkit - development files
libssl-doc - Secure Sockets Layer toolkit - development documentation
libssl-ocaml - OCaml bindings for OpenSSL (runtime)
libssl-ocaml-dev - OCaml bindings for OpenSSL
libssl-utils-clojure - library for SSL certificate management on the JVM
libssl1.0-dev - Secure Sockets Layer toolkit - development files
libssl1.0.2 - Secure Sockets Layer toolkit - shared libraries
libssl1.1 - Secure Sockets Layer toolkit - shared libraries
libssm-bin - macromolecular superposition library - binaries
libssm-dev - macromolecular superposition library - development files
libssm2 - macromolecular superposition library - runtime
libsss-certmap-dev - Certificate mapping library for SSSD -- development files
libsss-certmap0 - Certificate mapping library for SSSD
libsss-idmap-dev - ID mapping library for SSSD -- development files
libsss-idmap0 - ID mapping library for SSSD
libsss-nss-idmap-dev - SID based lookups library for SSSD -- development files
libsss-nss-idmap0 - SID based lookups library for SSSD
libsss-simpleifp-dev - SSSD D-Bus responder helper library -- development files
libsss-simpleifp0 - SSSD D-Bus responder helper library
libsss-sudo - Communicator library for sudo
libx32gcc-6-dev-amd64-cross - GCC support library (x32 development files)
libx32gcc-6-dev-i386-cross - GCC support library (x32 development files)
libx32gcc-8-dev-amd64-cross - GCC support library (x32 development files)
libx32gcc-8-dev-i386-cross - GCC support library (x32 development files)
perl-openssl-defaults - version compatibility baseline for Perl OpenSSL packages
php-ssh2 - Bindings for the libssh2 library
python-libssh2 - Python binding for libssh2 library
python-libsss-nss-idmap - Python bindings for the SID lookups library
python3-libsss-nss-idmap - Python3 bindings for the SID lookups library
r-cran-openssl - GNU R toolkit for encryption, signatures and certificates based on OpenSSL
ssh-audit - tool for ssh server auditing
tcode - create a Java file from an associated LaTex file
@raspberrypi:~ $ sudo apt-get update
@raspberrypi:~ $ sudo apt-get install php-ssh2
@raspberrypi:~ $ sudo service apache2 restart

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA