Thanks for repply. Below are the details:
On server C
ssh : OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
OS: CentOS release 5.8 (Final)
On server B
ssh: OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
OS: CentOS release 5.9 (Final)
Aha, I see what is happening! You are using a custom transport!!!
Probably, your script is quite old, from the days when Net::SFTP::Foreign didn't support password authentication directly and Expect was used to establish the connection and log into the server.
Nowadays, you can pass the user and password to Net::SFTP::Foreign constructor and let it handle everything for you.