Hi
I'm trying to work out if it possible to use perl to solve a problem I have
We use an authentication method which involves running ssh as one user and then using powerbroker once on the remote node to access a further user. e.g.What I'd like to be able to do is to have a perl wrapper provide the password at each step and end up with an interactive shell on the remote host. Note the use of ssh keys is disallowed.ssh myuser@myremotenode.com enter password here pbrun mygroup myremoteuser=ksh enter password here Access granted
I've taken a look at various perl modules to do this like Net::SSH::Expect and Net::OpenSSH but can't seem to get them to do what I'm looking for.
e.g. this code gets me access to the remote host by providing the answres to the prompts but won't leave me in an interactive shell (as though I was in a ksh)This allows me to connect via powerbroker as user2 on the remote host but I can only run a pre-determined set of commands.use Net::SSH::Expect; my $ssh = Net::SSH::Expect->new ( host => "remotehost.com", password=> 'mypass', user => 'user1', raw_pty => 1 ); # logon to the SSH server using those credentials. my $login_output = $ssh->login(); if ($login_output !~ /Last login/) { die "Login has failed. Login output was $login_output"; } $ssh->exec("stty raw -echo"); $ssh->send("pbrun mypbgroup user2=ksh"); $ssh->waitfor('Password:\s*\z', 3) or die "prompt 'Password' not found + after 1 second"; $ssh->send("mypass"); $ssh->waitfor('user2_prompt', 3) or die "prompt 'user2_prompt' + not found"; my $cmd1 = $ssh->exec('ls -l'); print ($cmd1); my $cmd2 = $ssh->exec('whoami'); print ($cmd2);
Using expect seemed like a reasonable idea to provide seamless entry
How can I change this so that it accepts any command as if I was logged into a shell interactively ? Is that possible ?Thanks in advance
In reply to Interactive conectin via SSH and Powerbroker by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |