This sounds like it is an authentication error from the remote end. Somehow, the remote end thinks that "you" ($ENV{USER}) are not the one connected to the public+private keypair.
Maybe $ENV{USER} is different from your expectations, or your program does something wrong.
I would look at what ssh does by connecting using ssh -i ~/.ssh/the-new-private-key -v -v -v and comparing that with my expectations, and very closely comparing that with the output of your program with $ssh2->trace(-1);.
In reply to Re^3: Net::SSH2 not base64 encoded
by Corion
in thread Net::SSH2 not base64 encoded
by averlon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |