LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-10-2008, 12:04 AM   #1
atrac
LQ Newbie
 
Registered: Oct 2007
Posts: 10

Rep: Reputation: 0
How can apache, a nobody user, perform scp


In Linux, each user you create using useradd has a home direcotry, something like /home/user.

In /etc/passwd there is an "apache" user.

I am running Apache and when the user enters a number in a web page in the browser, a CGI script (Perl) is executed and this is supposed to scp a file from a remote server.

But if I cannot su apache, how can I scp the file. I need to create the private and public keys.
 
Old 05-10-2008, 08:38 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What do you mean by "I cannot su apache"? As root you should be
able to do that; of course if nobody has a shell of false the
login won't last long ...


Cheers,
Tink
 
Old 05-10-2008, 10:09 PM   #3
rlhartmann
Member
 
Registered: Mar 2008
Posts: 73

Rep: Reputation: 16
I don't fully understand why you want to run an scp from a cgi-script, I would suggest that you be sure to have signifcant security in place for this task.

The web server should already be running as the apache user, so you do not need to su to apache. You can use the -i option with scp (and ssh) to point to the private key. If you generate your keys and then put the private key in a safe place that the user of the web server (apache) can access, then point to that file in your cgi script using the -i option, it should be able to copy the necessary files.

Last edited by rlhartmann; 05-10-2008 at 10:14 PM. Reason: Corrected grammar
 
Old 05-11-2008, 06:20 AM   #4
atrac
LQ Newbie
 
Registered: Oct 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks for suggesting the -i option. Let me try that out.

The story goes like this: A user has an ID which corresponds to the name of a text file in server 1.

Another server 2 running Apache, provides a web page for the user to enter the ID, and this triggers a script to copy that text file from the remote server, and then process it.

So, the user Apache needs to secure copy the file without entering passwords and then process it.
 
Old 05-11-2008, 09:24 PM   #5
atrac
LQ Newbie
 
Registered: Oct 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rlhartmann View Post
...You can use the -i option with scp (and ssh) to point to the private key. If you generate your keys and then put the private key in a safe place that the user of the web server (apache) can access, then point to that file in your cgi script using the -i option, it should be able to copy the necessary files.
Thanks, this works.
 
Old 05-12-2008, 09:37 PM   #6
rlhartmann
Member
 
Registered: Mar 2008
Posts: 73

Rep: Reputation: 16
Your welcome. Glad to help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using scp without user name and password psandeepnair1985 Linux - Networking 1 11-20-2007 08:12 AM
SCP with a system user dekers Linux - Networking 4 01-29-2006 12:05 PM
530 Must perform authentication before identifying USER. talk2me Linux - Networking 1 11-08-2004 04:51 AM
using gftp I need to perform authentication before identifying USER. pcpinkerton Linux - Security 3 04-18-2004 08:30 AM
SSH and SCP user logins sopiaz57 Linux - Security 11 01-27-2004 09:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration