Sponsored Content
Full Discussion: Problem with perl openssh
Top Forums Shell Programming and Scripting Problem with perl openssh Post 302466645 by dahlia84 on Wednesday 27th of October 2010 12:48:47 AM
Old 10-27-2010
Can you try something like this? Source: Net::OpenSSH

Quote:
mod_perl and mod_perl2

mod_perl and mod_perl2 tie STDIN and STDOUT to objects that are not backed up by real file descriptors at the operative system level. Net::OpenSSH will fail if any of these handles is used explicetly or implicitly when calling some remote command.
The workaround is to redirect them to /dev/null or to some file:
open my $def_in, '<', '/dev/null' or die "unable to open /dev/null";
my $ssh = Net::OpenSSH->new($host,
default_stdin_fh => $def_in);


my $out = $ssh->capture($cmd1);
$ssh->system({stdout_discard => 1}, $cmd2);
$ssh->system({stdout_to_file => '/tmp/output'}, $cmd3);

Also, note that from a security stand point, running ssh from inside the webserver process is not a great idea. An attacker exploiting some Apache bug would be able to access the ssh keys and passwords and gain unlimited access to the remote systems.
If you can, use a queue (as TheSchwartz) or any other mechanism to execute the ssh commands from another process running under a different user account.
At a minimum, ensure that ~www-data/.ssh (or similar) is not accessible through the web server!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problem installing openssh v2.9-p2

I am trying to install openssh v2.9-p2 on Solaris 8. I already installed zlib and openssl, as required in INSTALL file. But when I issue ./configure to configure openssh v2.9-p2 for my platform ( I got the sources), it stops in the folowing message: checking for OpenSSL directory... configure:... (1 Reply)
Discussion started by: htsubamoto
1 Replies

2. UNIX for Dummies Questions & Answers

OpenSSH

Help! SSH is returning the following error message: OpenSSL version mismatch. Built against 90581f, you have 90602f How can I correct this? (21 Replies)
Discussion started by: chenly
21 Replies

3. Shell Programming and Scripting

problem with perl

hi, i have a script that coverts the file time in epoch time.but the problem is perl is not working inside the k-shell ---------------------------------------------------------------- #!/bin/ksh echo "Enter the file" read n perl -e 'print ((stat("n")))'... (6 Replies)
Discussion started by: ali560045
6 Replies

4. UNIX for Dummies Questions & Answers

A problem about openssh

When I first link a computer with ssh , the information "Warning: Permanently added ... (RSA) to the list of known hosts." will be occured. How can i avoid this information without use the parameter '-q'? tks!!! (2 Replies)
Discussion started by: ragehunter
2 Replies

5. UNIX Desktop Questions & Answers

OpenSSH

Hello, I downloaded Cygwin to practice on my coursework from home. I was told to download the OpenSSH from Cygwin website so that I can access my files from home. However, the file saves itself with a cgi extension and I have no idea as to what I am supposed to do next. I found info on some... (1 Reply)
Discussion started by: feliks0
1 Replies

6. AIX

AIX 6.1 - openssh - problem

Hello, I am new in aix unix. First i install openssl - success, next step i try install openssh when i put command geninstall -Y -d /myssh openssh.base i have this message: What is the problem? Thanks for help. Sorry for my bad english i still learning. ---------- Post updated at... (2 Replies)
Discussion started by: bieszczaders
2 Replies

7. Fedora

OpenSSH Problem

Hello, I cannot seem to loggon to a machine using ssh/scp. Whenevr I do it closes the connection (error message : lost connection)but it appears to be the host machine closing rather than the destination which puzzles me even more. What is even weirder is that as a root user it works but as a... (1 Reply)
Discussion started by: mojoman
1 Replies

8. UNIX for Advanced & Expert Users

Problem with OpenSSH Remote Port Forwarding with Bind_address

As in the ssh(1) man page: -R bind_address:]port:host:hostport .......By default, the listening socket on the server will be bound to the loopback interface only. This may be overridden by specifying a bind_address. An empty bind_address, or the address `*', indicates... (2 Replies)
Discussion started by: ahmad.zuhd
2 Replies

9. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

10. Red Hat

Openssh 6.8

Hi im using redhat enterprise linux 7 im trying to update to the latest openssh version 6.8 i ran the command yum update openssh and this upgraded only to version 6.6 how can i update to the latest version 6.8? thanks! (5 Replies)
Discussion started by: guy3145
5 Replies
sftp-server(1M) 					  System Administration Commands					   sftp-server(1M)

NAME
sftp-server - SFTP server subsystem SYNOPSIS
/usr/lib/ssh/sftp-server DESCRIPTION
sftp-server implements the server side of the SSH File Transfer Protocol as defined in the IETF draft-ietf-secsh-filexfer. sftp-server is a subsystem for sshd(1M) and must not be run directly. There are no options or config settings. To enable the sftp-server subsystem for sshd add the following to /etc/ssh/sshd_config: Subsystem sftp /usr/lib/ssh/sftp-server See sshd_config(4) for a description of the format and contents of that file. There is no relationship between the protocol used by sftp-server and the FTP protocol (RFC 959) provided by in.ftpd. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/sftp-server ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsshdu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
sftp(1), ssh(1), ssh-add(1), ssh-keygen(1), sshd(1M), sshd_config(4), attributes(5) To view license terms, attribution, and copyright for OpenSSH, the default path is /var/sadm/pkg/SUNWsshdr/install/copyright. If the Solaris operating environment has been installed anywhere other than the default, modify the given path to access the file at the installed location. AUTHOR
Markus Friedl SunOS 5.10 30 Jul 2003 sftp-server(1M)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy