Net::SSH2::SFTP(3)
π Net::SSH2::SFTP β the SSH 2 Secure FTP object, bestie edition π
okay so this is the Net::SSH2::SFTP page from the Perl manual, and we are gonna make it make sense. sit with me. π«Ά
β¨ NAME β¨
Net::SSH2::SFTP</purl> β the SSH 2 Secure FTP object. that's it, that's the name, she's iconic, she's serving. π
πΈ DESCRIPTION πΈ
An SFTP object is not something you just... find in the wild. You make one β you get it by calling the sftp method on a Net::SSH2 object. that's the origin story. main character energy fr. β¨
π error
returns the last SFTP error. and when we say "the last SFTP error" we mean one of the LIBSSH2_FX_* constants, okay? π
reach for this one when Net::SSH2::error hands you back LIBSSH2_ERROR_SFTP_PROTOCOL β that's your cue, that's the signal, go get the real tea. π΅
and in list context, she gives you (code, error name). two things. a lil duo. π«Ά
π die_with_error( [message] )
calls die, but make it β¨informativeβ¨ β it takes your message and appends the error info from the object. so you die, but you die with context. π
π open ( file [, flags [, mode ]]] )
open or create a file on the remote host. remote!! not on your laptop!! π
the flags are the standard squad:
O_RDONLYO_WRONLYO_RDWRO_APPENDO_CREATO_TRUNCO_EXCL
and yeah you can combine them, as usual, like a little friendship bracelet. π§
defaults, bestie, write these down:
- flags default to
O_RDONLY - mode defaults to
0666(create only)
returns a Net::SSH2::File object on success. slay. π
π opendir ( dir )
opens a directory on the remote host. returns a Net::SSH2::Dir object on success. we love a return value that is an object. π
π unlink ( file )
delete the remote file. gone. deleted. no undo. π
π rename ( old, new [, flags ] )
renames old to new. π«
the flags come from LIBSSH2_SFTP_RENAME_*, and you can combine them. the default is to use all of them β overwrite, atomic, native. she does the most, on purpose, and honestly? respect. π
π mkdir ( path [, mode ] )
makes a directory. mode defaults to 0777. πβ¨
π rmdir ( path )
removes a directory. bye bye directory. π«Ά
π stat ( path [, follow ] )
gets file attributes for the given path. π
if follow is set β and it is set by default β she'll follow symbolic links. π¦
on success, returns a hash with all of this in it:
modesizeuidgidatimemtime
six keys. a whole little hash. π
π setstat ( path, key, value... )
sets file attributes for the given path. the keys are the same ones stat gives you back β same list, same names. π―
note: it is not necessary to pass them all. you can pass just the ones you care about. no pressure. π
π symlink ( path, target [, type ] )
creates a symbolic link to a given target. π
π readlink ( path )
returns the target of the given link. and if it fails? undef. π that's it, that's the failure mode.
π realpath ( path )
resolves a filename's path. returns the resolved path, or undef on error. π§
π SEE ALSO π
- Net::SSH2.
- Check Net::SFTP::Foreign if you want a high level, perlish and easy to use SFTP client module. she's giving convenience. π and guess what β it can work on top of Net::SSH2 via the Net::SFTP::Foreign::Backend::Net_SSH2 backend module. iykyk. π«Ά
β AUTHOR β
David B. Robins, <dbrobins@cpan.org> β ty for your service king π«‘π
π COPYRIGHT AND LICENSE π
Copyright (C) 2005, 2006 by David B. Robins; all rights reserved. yes, all of them. every single right. π
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. so like. go forth. remix. πβ¨
and that's the whole page, bestie!! this was Net::SSH2::SFTP(3), part of perl v5.42.0, dated 2025-07-25 β mwah, no cap, fr fr, go open some remote files responsibly. ππ¦πΈππ π«Ά
π¦ where this page comes from
- fedora 43: perl-Net-SSH2 0.74-4.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms