Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log out when using Net::SFTP

Tags:

perl

I'm trying to get started with Net::SFTP, but I wasn't able to find in its documentation or in the documentation for Net::SSH::Perl, how we're supposed to log out of the SFTP server.

What am I missing?

Is logout handled by garbage control?

like image 982
theglauber Avatar asked Jun 08 '16 21:06

theglauber


People also ask

How do I exit SFTP connection?

Exit sFTP ShellType 'exit' command where we can see sftp> prompt return.


1 Answers

You can't.

I've looked at the source code for both Net::SFTP and Net::SSH::Perl. Neither of them has a DESTROY method, so there is no explicit cleanup being done. There are also no disconnect or quit or similar.

Net::SSH::Perl has a sub _disconnect which is empty. It's called by sub fatal_disconnect. fatal_disconnect is used by Net::SFTP in case an SFTP request failed. But that's it. Nothing else.

The objects get cleaned up by Perl as soon as they go out of scope.

{
    my $sftp = Net::SFTP->connect; # example
    # do stuff...
}

# here it has been cleaned up and DESTROY was called on it

But since there is no code, nothing else happens. I cannot find code that tells the SSH to log out. Maybe it just times out. We would have to look at the server logs to see what happens.

like image 73
simbabque Avatar answered Oct 07 '22 00:10

simbabque