I can't see why your script behaves differently when you put the login parameters in a different module but in any case, instead of mixing them all in one string, you can pass then to Net::OpenSSH as different arguments:
my $ssh = Net::OpenSSH->new($host,
user => $user,
password => $password,
timeout => 10);