前端使用xtermjs,后端使用swoole v6,实现的web ssh。只是demo。 php需ssh2扩展,php>=8.3,低版本请自行修改不兼容写法。
参考项目: https://github.com/roke22/PHP-SSH2-Web-Client
s12765:~/php# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
gd
hash
iconv
igbinary
json
libxml
mbstring
msgpack
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
random
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
ssh2
standard
swoole
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
s12765:~/php# php --ri swoole
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 6.0.1
Built => Feb 17 2025 03:17:26
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 3.3.3 11 Feb 2025
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
curl-version => 8.12.1
zlib => 1.3.1
brotli => E16781312/D16781312
mutex_timedlock => enabled
pthread_barrier => enabled
Directive => Local Value => Master Value
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
s12765:~/php# php --ri ssh2
ssh2
SSH2 support => enabled
extension version => 1.4.1
libssh2 version => 1.11.1
banner => SSH-2.0-libssh2_1.11.1
s12765:~/php# php -v
PHP 8.3.17 (cli) (built: Feb 12 2025 01:02:12) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.17, Copyright (c) Zend Technologies
with Zend OPcache v8.3.17, Copyright (c), by Zend Technologies