简体   繁体   English

在本地主机中连接到 ssh2

[英]Connecting to ssh2 in localhost

When I run following code in localhost in Xampp I saw an error that the connection was not success.当我在Xampp localhost中运行以下代码时,我看到连接不成功的错误。 Now I want know How Can I connect to ssh2 in localhost in Windows in Xampp and what is Username and Password for this connection.'现在我想知道如何在Xampp Windows中连接到localhost中的ssh2以及此连接的UsernamePassword是什么。 :

ssh2_connect('127.0.0.1','');

For connect to ssh2 in localhost in Windows with Xampp:-使用 Xampp 连接到 Windows 本地主机中的 ssh2:-

1) Download SSH2 PECL library from PHP.net 1) 从PHP.net下载 SSH2 PECL 库

2) Extracted the archive's content:- 2)提取档案的内容:-

(2.1)copied/replaced libssh2.dll file to C:\Windows\system32

(2.2)placed php_ssh2.dll and php_ssh2.pdb files in the ext folder (e.g. C:\xampp\php\ext);

3)Remove ';' 3)删除';' from the ;extension:php_ssh2.dll line in php.ini.来自 php.ini 中的 ;extension:php_ssh2.dll 行。 If this line is not on your php.ini, add it.如果此行不在您的 php.ini 中,请添加它。

4) restart the apache server. 4)重启apache服务器。

Connecting code:-连接代码:-

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream = ssh2_exec($connection, '/usr/local/bin/php -i');
?>

For you i have a perfect solution Try installing wamp and then going in directory c:/wamp/ .. And then the folder for local host.. Turn try turning on the wamp service u installed above.对于你,我有一个完美的解决方案 尝试安装 wamp,然后进入目录 c:/wamp/ .. 然后是本地主机的文件夹.. 尝试打开上面安装的 wamp 服务。 VIOLA!薇奥拉!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM