in reply to Problem to connect remote host

Is that code snippet the one you are running? I doubt it, since

Furthermore, it's a good idea to ping the machine first, and then attempt to ssh into it.

Last but not least don't double-quote single variables as in the useless interpolation

Net::SSH::Perl->new ("$hostname");

Say rather

Net::SSH::Perl->new ($hostname);

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}