Create a new class derived from Net::SSH::Perl and redefine the _connect method to do whatever you want. For instance, implementing the SOCKS5 protocol yourself (it's a very simple one) or using an external SOCKS5 adapter connected by a pipe or a unix socket.