I was using Net::SSH2 perl module for connecting to remote system and executing fews command there.
With the new requirement in the project, we had to switch user using su command to a previllaged user and execute few privileaged commands there.
We are connected to remote system using normal user with Net::SSH2 function and here is the below code
But after we connect using a normal user and try to switch to a privileged user for which the below is the continued codemy $ssh2 = Net::SSH2->new(); eval {$ssh2->connect($rip) ; }; if( $@ ) {print qq{ Error: Cannot connect to $rip : SSH service Failed +}; exit 1; } return "Error: Authenticate fail for $rip" unless $ssh2->auth( +username => $rusr,password=>$rpwd); $chan2 = $ssh2->channel; die "Can not create a shell on channel " unless $chan2->shell; die "Can not set blocking field " unless $chan2->blocking(0); $chan2->ext_data('merge'); $ssh2->auth(username => $rusr,password=>$rpwd);
when we execute this script it is giving the following output:print $chan2 "su $user2 \n"; print $chan2 "$pass2 \n";
<code> standard in must be a tty </code
Can any one suggest me how to integrate this switching of user using Net::SSH2
Thanks in advance,
In reply to Switch to different user using Net::SSH2 perl module by msk_0984
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |