LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-29-2010, 11:14 PM   #1
bianchi77
Member
 
Registered: Jul 2009
Posts: 51

Rep: Reputation: 15
Could not create directory ssh solution....?


Friends,

Can you help with this :
.....
I try to run in php script..
================
shell_exec("ssh admin@192.168.1.13 reboot");
===============
in php....I have put the key on server...

i can ssh server without a password..

i got "Could not create directory ssh... " error message from that php script...

if i did "ssh admin@192.168.15 reboot" from shell it works ok....

Anyone ever experience this ? can you share ?

Any helps will be very appreciated..

Tx

Last edited by bianchi77; 04-29-2010 at 11:17 PM.
 
Old 04-30-2010, 03:56 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Why not
Code:
exec("ssh admin@192.168.1.13 reboot");
If you want to run it from a webserver you need the key of the user that the webserver runs as

Regards

Last edited by bathory; 04-30-2010 at 08:45 AM. Reason: info
 
Old 05-01-2010, 10:56 AM   #3
bianchi77
Member
 
Registered: Jul 2009
Posts: 51

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bathory View Post
Why not
Code:
exec("ssh admin@192.168.1.13 reboot");
If you want to run it from a webserver you need the key of the user that the webserver runs as

Regards
can you explain how ?

thx
 
Old 05-01-2010, 12:31 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
What how?
You should tell us what you want to do and we'll see how we can help.

But, if you want to use a webserver to run system commands, and you're absolutely sure about this (as it's a security risk), it's better to setup sudo for the user that runs the webserver. This way you can limit that user to run specific commands only.

Regards
 
Old 05-01-2010, 11:24 PM   #5
bianchi77
Member
 
Registered: Jul 2009
Posts: 51

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bathory View Post
What how?
You should tell us what you want to do and we'll see how we can help.

But, if you want to use a webserver to run system commands, and you're absolutely sure about this (as it's a security risk), it's better to setup sudo for the user that runs the webserver. This way you can limit that user to run specific commands only.

Regards
i want to run :

exec("ssh admin@192.168.1.13 reboot");
from my php script...but confuse with user problem ..
should i change the user at httpd.conf, the same with user i login ??

tx
 
Old 05-02-2010, 01:48 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Yes, it's more easier to change the user that runs apache (I guess you run apache since you mentioned httpd.conf) and make it be admin. Of course this has to be a non-privileged user for security reasons.

Or you can create a public key for the current apache user and add it to ~/authorized.keys for admin at 192.168.1.13

Regards
 
  


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
How to create SSH user without access to root directory victorsk Linux - Networking 1 08-07-2009 06:56 PM
mkdir : cannot create directory : no such file or directory patcheezy Linux - Newbie 6 05-13-2009 11:26 AM
Create Directory? ssh/svn help WestsideGuy Linux - Newbie 2 07-23-2008 03:28 PM
C++ compiler cannot create executables (solution) DennisC31 Linux - Newbie 2 07-08-2008 02:38 PM
Active Directory Solution in Linux Zakirium Linux - Networking 4 02-12-2005 09:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:20 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