The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2008
Registered User
 

Join Date: Apr 2007
Posts: 4
PHP and SCP

How do I get PHP to use SCP?

I have tried using expect in a shell script and then passing it hostname, username and password.

The shell script works if it's run it from the command line (logged in as apache) but if I run it from a PHP script it doesn't work and I can't figure out why.

The web front end needs to:
- collect hostname, username, password
- log into remote machine
- transfer tar file from host machine to local machine
- expand tar file on local machine

Any suggestions would be greatly appreciated...

Thanks,
~Donavon
Reply With Quote
Forum Sponsor
  #2  
Old 01-16-2008
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
I would suggest you use public keys instead of passwords for something like this. Then the user would not need to enter any username/password. Of course you front-end should be authenticated via some other means(ldap,file, etc..)

be very careful with your input parameters

check out PHP: Program Execution - Manual
Reply With Quote
  #3  
Old 01-16-2008
Registered User
 

Join Date: Apr 2007
Posts: 4
Public keys can't be used in this situation.
Reply With Quote
  #4  
Old 01-16-2008
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
my guess is that your script might be breaking because there is no terminal while running under apache and expect will not be able to read stdin.
Reply With Quote
  #5  
Old 01-16-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Quote:
Originally Posted by djlerman View Post
How do I get PHP to use SCP?
this is just an example
Code:
<?php
$conn = ssh2_connect('ftp.server.com', 22);
ssh2_auth_password($conn 'user', 'pass');
ssh2_scp_send($conn, '/local/filename', '/remote/filename', 0644);
?>
Reply With Quote
  #6  
Old 01-16-2008
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
sweet. I did not realize PHP had an API for ssh. learn something new every day.
Reply With Quote
  #7  
Old 01-16-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Quote:
Originally Posted by frank_rizzo View Post
sweet. I did not realize PHP had an API for ssh. learn something new every day.
It can be downloaded from PECL here
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0