Re: Expect script to install sshkey



Wiggins d'Anconia wrote:
Ramprasad A Padmanabhan wrote:

Hi all,
I have a perl Expect script that install rsa keys for ssh auto login.
When I run the script on command line it works fine.
Now when I run it inside a CGI the script simply gets stuck. I can see
from the from the SSH server and also the expect logs that the login is
happenning. But After login nothing happens :-(
The commands I give to append the authorized_keys2 file are not executed
at all.


Are the keys readable by the web server user? Sounds like a permissions
problem.


The problem is not with permissions. Actually this is the part script where it hangs


.......
# $exp is the expect object
$exp->expect(10,
'-re' , $prompt , \&inter,
'-re',"password:",sub {}) or die "Couldnt get pass prompt\n";
$exp->send("$password\r");
$exp->expect(10, -re , $prompt) or die "Couldnot login\n";

# Until here it is fine. I can see in the ssh logs that login has happened
# The foll commands work if run on commandline only
$exp->raw_pty(1);
$exp->send("\r");
my $cmd = "lynx -source http://192.168.2.32/rsakey.txt >> ~/.ssh/authorized_keys2\r";
$exp->send($cmd);
$exp->send("\r");
$exp->send("sleep 1 && exit\r");

# The next step is compulsory else nothing works even on command line
# I dont understand why
$exp->interact();
exit(0);

###############################
I can attach my entire script if necessary



Thanks
Ram




.



Relevant Pages

  • Re: Hacker activity?
    ... >login to a server, most as root but some are attempts to login to ... >telnet, all come from the same remote server, and all fail. ... >getting some odd cgi calls to a script on a secure ssl server. ... Make sure root cannot login to your system via ssh. ...
    (freebsd-questions)
  • Scripts using SSH and SSH_ASKPASS
    ... To test SSH scripts you better destroy the control TTY. ... The trick is to run YOUR script on YOUR local ... As for the password relaying command: this needs not be an X command. ... # we read one line from a temporary pipe. ...
    (comp.security.ssh)
  • Re: remote server backup script
    ... > Just type away at the command line. ... Make a backup of whatever you want ... > command line, in a script. ... >>the server ssh key on the clients machine). ...
    (comp.os.linux.misc)
  • Re: [PHP] SSH and php
    ... % % Is it possible to run a SSH command from php? ... it's possible to run any command from php. ... There are ways to do that -- I personally would create a kick script ...
    (php.general)
  • Re: Expect script to install sshkey
    ... you have mentioned that you are using "lynx" for the download, would it be possible you to use wget/any other file retrieval utility from www rather than a information browser. ... I have a perl Expect script that install rsa keys for ssh auto login. ... When I run the script on command line it works fine. ...
    (perl.beginners)