LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-14-2005, 01:07 AM   #1
GaijinPunch
Member
 
Registered: Aug 2003
Location: Tokyo, Japan
Distribution: Gentoo
Posts: 130

Rep: Reputation: 22
SSH-key for apache user?


Okay, this may seem rather ghetto, but I need the apache user to be able to ssh to another machine to peak around. You can't just su to this user and make the keys, so I'm kind of screwed. I've tried configuring my remote machines to allow rhosts authentication...which doesn't seem to work in this case, most likely b/c apache isnt' a real user.

Any clues?
 
Old 06-14-2005, 04:19 PM   #2
GaijinPunch
Member
 
Registered: Aug 2003
Location: Tokyo, Japan
Distribution: Gentoo
Posts: 130

Original Poster
Rep: Reputation: 22
NOBODY knows anything about this?
 
Old 02-04-2009, 01:48 PM   #3
afrorobot
LQ Newbie
 
Registered: Jun 2008
Distribution: Fedora 14
Posts: 10

Rep: Reputation: 0
I know this thread is old... but...

I figured out a workaround for this (for all you kids googling this issue out there) but I doubt it is secure, but I am running it for testing scripts from PHP in a virtual environment so that doesn't matter to me.

Since the APACHE user's home is "/var/www" and ssh-keygen requires access to /var/www/.ssh but cannot create it because there is no shell you can do the following.

Code:
mkdir /var/www/.ssh
chown -R apache:nobody /var/www/.ssh
sudo -u apache ssh-keygen -t rsa
For ssh-keygen just press enter if you want to test otherwise fill in some values to secure your stuff!
Code:
sudo -u apache ssh-copy-id -i /var/www/.ssh/whatever.pub root@host
And you are done!
 
Old 10-16-2009, 02:28 PM   #4
WarrenTR
LQ Newbie
 
Registered: Oct 2009
Distribution: Gentoo, Ubuntu, CentOS
Posts: 1

Rep: Reputation: 0
afrorobot,
Thanks for this solution. It seems to work just fine, but when I try to use rsync to another machine, I get these errors:

rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.5]
 
Old 02-02-2011, 04:48 AM   #5
Comfortably Paranoid
LQ Newbie
 
Registered: Feb 2011
Posts: 2

Rep: Reputation: 0
If you want to use this with keychain, then there is a bit more work to do. Use keychain since the apache user cannot enter a password.

Code:
mkdir /var/www/.keychain
chown apache:nobody /var/www/.keychain
chmod 700 /var/www/.keychain
(note chmod 600 does not work!)

You need to add a known_hosts file to /var/www/.ssh/, I copied one from my user account on the same machine and changed the ownership. In general, make sure you are following the ownership/permissions that are required by ssh.

Call keychain before making your scp/rsync command. The following is all one line, called by the PHP shell function:

Code:
/usr/bin/keychain --dir /var/www/.keychain /var/www/.ssh/id_rsa ; 
source /var/www/.keychain/LOCALHOSTNAME-sh ; 
scp YOURFILE USERNAME@REMOTEHOST:~/
I hard coded the local hostname rather than trying to figure out if the env variables were set up properly.

I found the following page Debugging SSH public key authentication problems useful. I used scp -vvv -B during debugging.

Note that I'm on Fedora, and I have no idea about the security of doing things like this.

Last edited by Comfortably Paranoid; 02-02-2011 at 05:00 AM.
 
  


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
Can't SSH as Apache user GaijinPunch Linux - Networking 6 11-27-2005 04:47 PM
ssh using public key jkmartha Linux - Networking 1 05-04-2005 02:52 AM
ssh Host Key ziox Linux - Networking 6 02-07-2005 02:57 PM
SSH Global Key? kuronai Linux - Networking 3 08-18-2004 12:23 AM
ssh / ssh-key -- its always asking for passphrase BaerRS Linux - General 1 01-07-2003 06:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:24 PM.

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