I am using PHP , I want to connect to remote server in SFTP, but the website said:
Fatal error: Call to undefined function ssh2_connect() in D:\xampp\htdocs\dive\database.php on line 9
Can you tell me in detail how to do this? I tired
<?php
$connection = ssh2_connect('ftp.server.com', 22);
if (ssh2_auth_password($connection, 'username', 'password'))
echo "Authentication success";
else
echo "Authentication failure";
?>
But it doesn't work.
After I connect to the server, is there a difference if I want to insert some data to the table in it? Which function should I use?
Have you installed / verified via phpinfo() that ssh2 is installed?
Quick Google search seems to indicate it is not by default
PHP Install SSH2 on Windows machine
Related
I've setup mysql server 8.0, Apache2.4, php 7.2 and created a simple database.
As a start I am trying to write a php code for connecting to the database but i can't figure it out.
My code:
<?php
$con = mysqli_connect("localhost","Don","password","db1");
if (!$con) {
echo "Error: " . mysqli_connect_error();
exit();
}
echo 'Connected to MySQL';
?>
I get Error: The server requested authentication method unknown to the client.
I've tried several things: connect to root, 192.168.0.1 instead of localhost but nothing is working.
Any ideas? Thanks.
(post for someone who has the same problem)
i searched about the old password issue but i couldnt find the old_passwords var, not even in my.cnf file.
so what i did was uninstalling mysql server 8.0 and installing 5.7.2 and it worked.
ps i didnt configure anything differently while setting up the 5.7.2 version.
In PHP, I cannot even get the SFTP connection to work. I have tried to use the native SFTP functionality (ssh_connect), and it fails to connect. I have also tried to use phpseclib, but it fails as well. Neither of my aforementioned attempts have provided much in the way of log info.
The native code:
if (!function_exists('ssh2_connect')) {
echo "dll not loaded properly"; //never see this, so I know it works
return false;
}
$connection = ssh2_connect('sftp.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);
phpseclib library code:
include('Net/SFTP.php');
$sftp = new Net_SFTP('sftp.example.com');
if (!$sftp->login('username', 'password')) {
exit('Login Failed');
}
I have also tried to track all of the transactions via Fiddler to see if I at least see a connection being made, and I do see an error in the browser (below) that from googling may mean that a connection was made to the server, but no responses.
[Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 17139 bytes.
Why am I able to connect to the URL with the username and password via FIleZilla, but not from within php? Do I need some other DLLs in PHP's /ext folder (e.g. php_openssl.dll, etc.)?
Thanks,
Sean
I have installed the ssh2 extension and even have it enabled. i have also enabled openssl. Everything seems fine, but when i try to connect to a server i am getting ssh2_connect() unable to connect error. The server i am trying to access is accessible from my machine, i connected to the server via the terminal but when i run the script on my machine it is unable to connect to the server, any ideas what is going wrong here ?
I would appreciate it if you guys could point out som possible reasons that i can check/debug!
My script is like this:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
PS: i know there is a libary(phpseclib) that i can use, but i want to use ssh2 extension
Thanks :) !
We just have a transfer from old Windows Server, to the new Windows Server 2012.
After that transfer new XAMPP was installed, and I recognized, that mssql_connect was discountinued some time ago. So I checked that last version when it was supported was 5.2.
So I reinstalled XAMPP for older one but I still can't make it work.
I am getting error:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: SERVER/SQLEXPRESS in F:\xampp_php5.2\htdocs\open_db.php on line 2
Error!
My file looks like this:
<?php
$link = mssql_connect("SERVER/SQLEXPRESS","login", "pass") or die("Error!");
mssql_select_db("dbinet") or die("DB not exist");
echo 'success';
?>
I can login to this server (SERVER/SQLEXPRESS) using login and pass directly by SQL Server Managment Studio, but can't by webpage...
Any idea where is a problem?
I cannot get my local environment, Win7 running easyPHP 12, to connect to my server, ubuntu 11.04.
I connect to my server via sftp with filezilla fine, i can connect to my server via ssh with putty fine... the server requires no keys at the moment just a uname and pword...
I don't get it, the details i am passing via the php script are exactly the same as the ones i pass from filezilla and putty.
This is the code stripped to the bare basic:
//inlcude the phpseclib path in the include array and include the ssh2 class
set_include_path( WEBROOT_PRIVATE.'scripts/phpseclib0.3.0' );
if(!include('Net/SSH2.php')){
echo 'Sorry failed to load SSH2 class';
br();
}
if(!include('Net/SFTP.php')){
echo 'Sorry failed to load SFTP class';
br();
}
$connection = new Net_SFTP( 'xx.xx.xx.xx', 'xx' );
echo 'ss';
$login = $connection->login( 'username', 'password');
exit();
And this is the response i am getting:
Notice: Cannot connect to xx.xx.xx.xx. Error 10060. A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in
....\www_private\scripts\phpseclib0.3.0\Net\SSH2.php
on line 776 ss
Most likely server requires keyboard-interactive auth, while component tries password auth.
It's failing with fsockopen with the error that you're getting, which suggests to me it's not a phpseclib problem so much as a PHP one.
So the way SSH works is that the server sends a banner immediately to you when you try to connect. It does that for stackoverflow.com for example:
<?php
$fsock = fsockopen('www.stackoverflow.com', 22);
echo fgets($fsock, 1024);
When I run that script I get "SSH-2.0-OpenSSH_5.3" back.
My guess would be that if you update that PHP script to work with your server you'll get the same error message phpseclib is giving you.