Click here to Skip to main content
15,887,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,
I have written code of ssh connection with php. But it do not response result.
Please would u mind to help me?
The code is this
?php
$con = ssh2_connect("192.168.8.35", 22);
ssh2_auth_password($con,"root","root123");

if(ssh2_sftp($con))
{
echo "connected to 192.168.8.35";
}
else
{
echo "not connected";
}
?
Posted
Updated 4-Aug-10 5:37am
v3

1 solution

$ip = "192.168.8.35";

$con = ssh2_connect($ip, 22);

ssh2_auth_password($con, "root", "root23");

if(ssh2_sftp(con))
{

echo 'Connected to '.$ip;

} else {

echo 'Not Connected';

}
?>
 
Share this answer
 
v2
Comments
Peter_in_2780 16-Aug-10 20:55pm    
Reason for my vote of 1
Putting the IP address in a variable rather than literal changes nothing to do with the connection failing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900