Net::SS...l::Auth(3)

πŸ“¦
version 2.144 Β· 4 versions
, in fedora 44

πŸ’– Net::SS...l::Auth(3) πŸ’–

okay bestie so this is a page from the User Contributed Perl Documentation collection, and it's literally about the authentication guts of Net::SSH::Perl. come sit with me, we're doing this together 🫢


✨ NAME ✨

Net::SSH::Perl::Auth β€” the base authentication class, plus a whole lil toolkit of utility methods 🌸


🌈 SYNOPSIS 🌈

use Net::SSH::Perl::Cipher;

# Get list of supported authentication IDs.
my $supported = Net::SSH::Perl::Auth::supported();

# Translate an auth name into an ID.
my $id = Net::SSH::Perl::Auth::id($name);

# Translate an auth ID into a name.
my $name = Net::SSH::Perl::Auth::name($id);

# Get the order in which auth methods are tested.
my $order = Net::SSH::Perl::Auth::order();

like... look at her go πŸ’… so much utility, so much slay.


πŸ¦‹ DESCRIPTION πŸ¦‹

Net::SSH::Perl::Auth is the base class for every single one of the authentication method classes β€” she's the mother of the house, the main character, the blueprint πŸ‘‘

and ALSO she defines a set of utility methods that you can call either as plain functions or as object methods. flexible queen behavior, no cap ✨


πŸŽ€ UTILITY METHODS πŸŽ€

supported( [ $auth_id [, $server_supports ] ])

the vibe check of auth methods, fr fr πŸ’«

  • with no arguments β€” returns a reference to an array of the auth methods that Net::SSH::Perl supports. basically these are the methods that have actual working Net::SSH::Perl::Auth:: implementations. no ghost methods here bestie πŸ‘»
  • with one argument, $auth_id β€” returns a true value if that auth method is supported by Net::SSH::Perl, and false otherwise. simple as πŸ“
  • with two arguments, $auth_id and $server_supports β€” returns true if the auth represented by $auth_id is supported both by Net::SSH::Perl and by the sshd server. the list of methods supported by the server lives in $server_supports, which is a bit mask sent from the server during the session identification phase πŸ”₯

and here's the tea: you can call it as a non-exported function, like

my $i_support = Net::SSH::Perl::Auth::supported();

OR as an object method of a Net::SSH::Perl::Auth object, or an object of a subclass. and bestie, when you do it that way, the first argument should be $server_supports, not the $auth_id β€” yes it's giving plot twist but that's just how she is πŸ’€

if ($auth->supported($server_supports)) {
    print "Server supports auth method $auth";
}

id( [ $auth_name ] )

translates an auth method name into an ID β€” which is suitable for sending to the sshd server, for example 😌

  • if given $auth_name, translates that name into the corresponding ID
  • if called as an object method, translates the object's auth class name into the ID

name( [ $auth_id ] )

the reverse glow-up: translates an auth method ID into a name πŸ’–

  • if given $auth_id, translates that ID into the corresponding name
  • if called as an object method, returns the (stripped) object's auth class name. for example, if the object were of type Net::SSH::Perl::Auth::Rhosts, name would return Rhosts ✨

auth_order()

returns a reference to an array containing auth method IDs πŸ‘‘

these IDs describe the order in which authentication should be tested against the server. so, for example, if the array listed (2, 4, 3), then the client should test: RSA, then Rhosts-RSA, then Password authentication. the itinerary is scheduled, bestie, and she sticks to it πŸŽ€


πŸ’œ AUTH USAGE πŸ’œ

Net::SSH::Perl::Auth->new($auth_name, $ssh)

instantiates a brand new auth object of the type $auth_name, and hands it the Net::SSH::Perl object $ssh 🫢

that $ssh object should contain an open connection to an sshd server β€” no connection, no party.

returns the auth object, which will be blessed into the actual auth subclass. iconic class inheritance moment πŸ’…

$valid = $auth->authenticate()

talks to the sshd server to authenticate the user πŸ—£οΈ

  • if valid β†’ returns true
  • if invalid β†’ returns false

that's it, that's the whole dramatic exchange 😭


🌸 AUTH DEVELOPMENT 🌸

if you're out here writing classes that implement an authentication method, you must implement these following two methods. non-negotiable, bestie, it's the law ⭐

  1. $class->new($ssh) β€” given a Net::SSH::Perl object $ssh, should construct a new auth object and bless it into $class, presumably. (the "presumably" is doing a lot of heavy lifting here and honestly? same πŸ™ˆ)
  2. $class->authenticate() β€” authenticate the current user with the remote daemon. this requires following the messaging protocol defined for your authentication method. all of the data you need β€” user name, password (if required), etc. β€” should be in the $ssh object. returns 1 if the authentication is successful, 0 otherwise βœ…
⚠️ like genuinely, follow the messaging protocol for your method. it's not optional and she will notice.

πŸ‘‘ AUTHOR & COPYRIGHTS πŸ‘‘

please see the Net::SSH::Perl manpage for author, copyright, and license information. all the legal girly details live over there, i'm just the messenger πŸ’–


and that's the whole page, bestie!! no cap, you now know auth better than half the people who claim they do 🧚

this was perl v5.42.0, dated 2026-01-17, brought to you by the fine folks at Net::SS...l::Auth(3). mwah, go slay πŸ’…βœ¨

πŸ“¦ where this page comes from