SSH2_connect
Moderator: General Moderators
SSH2_connect
I am using SSH2_connect for ssh connection to an SFTP server. I want to close the connection after performing some SFTP function. What is the PHP function to disconnect from a SSH2_connect?
Re: SSH2_connect
Hmm, Im not sure about that, Once you are connected, Try to use
That should secure it a bit, Erm, After you
My code is probably completely wrong, Still picking php up so. My try 
Code: Select all
ssh2_fingerprint()Code: Select all
echo "You have been logged out";
}
die;Re: SSH2_connect
What does ssh2_fingerprint do? It has nothing to do with disconnect? I am looking for a function to disconnect me from the server once I get connection to it using ssh2_connect.
Re: SSH2_connect
Yeah i think you can just use the Die; Functions, The fingerprint is to secure logging in. You can see how to use it here,
http://www.php-manual.at/function.ssh2-fingerprint.html
http://www.php-manual.at/function.ssh2-fingerprint.html
Re: SSH2_connect
I am assumuing that there is no ssh2_disconnect.
ssh2_connect();
write or read some functions // this will write and read files on the sftp server
ssh2_disconnect();
ssh2_connect();
write or read some functions // this will write and read files on the sftp server
ssh2_disconnect();
Re: SSH2_connect
I had a look and i couldn't see one.
Shouldn't it exit when you close the page?
Shouldn't it exit when you close the page?
Re: SSH2_connect
~BlitZ wrote:Hmm, Im not sure about that, Once you are connected, Try to useThat should secure it a bit, Erm, After youCode: Select all
ssh2_fingerprint()My code is probably completely wrong, Still picking php up so. My tryCode: Select all
echo "You have been logged out"; } die;
I my application I use php as a script, where I need to connect through SSH2 to a lot of linux box'es.
I therefore need to be able to disconnect.
I too was also wandering about how to disconnect from a ssh2 connection, as I can not make it disconnect before the script ends.
(Its nice that I am not only one who does not understand it)
The "ssh2_fingerprint()" has nothing to do with disconnecting: (sorry...)
http://www.php.net/manual/en/function.s ... rprint.php
It just makes you able to verify the host.
I tried using "die;" at the end of my function, but it does not close the connection fully!
I get the same result as when using "unset($connection_ssh);" on my connection
($connection_ssh = ssh2_connect($connect_str['ip'], $connect_str['port']))
Just for test purpose:
If I pause the script at the end I can see that the SSH2 connections does not close fully until PHP ends.
To test this on Windows I use the command "netstat -b" in the command prompt, where I can see the following:
Trimmed output from the command prompt:
TCP dkmvpn7aaa:2748 192.168.117.11:ssh CLOSE_WAIT 10644
[php.exe]
TCP dkmvpn7aaa:2754 192.168.117.11:10022 CLOSE_WAIT 10644
[php.exe]
Re: SSH2_connect
Fingerprint function is for when you are logging in not when you are logging out, I think it just secures who is accessing it.
And with the Die; function not fully closing it, I'm stuck. I don't think there is another way :/
I'll just keep searchin google for a way
.
And with the Die; function not fully closing it, I'm stuck. I don't think there is another way :/
I'll just keep searchin google for a way