Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl using ssh

Status
Not open for further replies.

wytyspy

IS-IT--Management
Jul 22, 2005
5
US
Hi,

I have a perl script which does an ssh to another system for an ls of a directory. The command used in the script is:
ssh computer dir /archive/myfile

I recieve the message that the remote pc cmd failed.

However, if I do the same command from a command line in a shell it gives me the directory listing. Why does this command work from the command line and not in the perl script?

Thanks for any feedback.

Lucy
 
Isn't this going to try to log in with no identity (i.e. Perl)

ssh -l loginName ...


Kind Regards
Duncan
 
I have generated keys so I do not have to give it a password. It allows me to log in with no password
 
I have also tried it with logging in with the -l username and without with the same results.
 
What userid is the perl script running as?
Are you sure that it's running as the same userid that you test with manually?

This is not being run as CGI is it?



Trojan.
 
It is the same user in testing manually and in trying to use it in the script. No it is not being run as CGI. I am wondering if it has something to do with stdin or stdout?
 
weird... i have just set this up & all works fine from Perl (ssh2)


Kind Regards
Duncan
 
Thanks for all the responses but I just found out why this may not be working. The person who created the perl script did a setuid to another user and is running the program as userA. The setuid is set for userB. I believe that this is the problem. I am probably in the wrong forum for answering this question but does anyone know if you can ssh from a perl script that is running as userA with setuid set to userB? This may be tricky unless I can fool ssh-keyagent. At one point this was a bug where one could use ssh and get another user key but I think that the hatch was buckled down on that bug.

Thanks for all the feedback all.

Have a good weekend.
 
using ssh -l loginname won't help as then he will be asked for password, right? The key that he generated won't work for the other effective userID ( I guess :-/ )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top