它需要在 ssh 会话中创建文件“index.php”。
使用:“phpseclib/phpseclib”:“~2.0”,
$ssh = new SSH2("192.168.138.5", 22);
$ssh->login("user", "mypass");
$ssh->write("cd /home/user/\n");
$ssh->read('[prompt]');
$ssh->exec("cat > index.php <<EOF
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/header.php');
EOF\n");
$ssh->disconnect();
unset($ssh);
但结果是:
<?php
include(['DOCUMENT_ROOT'] . '/header.php');
如何在 ssh 会话中将“$_SERVER”文本写入文件?
白衣非少年
暮色呼如