Execution problem unix commands in Perl CGI


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution problem unix commands in Perl CGI
# 15  
Old 01-06-2012
Yes i have done already passwordless access.It means when i run this command on unix terminal it dont for password.
On terminal i run like:
ssh username@machinename 'ls dirname' ##it never promp me for password
# 16  
Old 01-06-2012
Good.

ssh uses your ~/.ssh/id_rsa file to log in without a password. The server you want into compares that with a key you gave it. ssh is extremely particular about who is allowed to read this file -- for your webserver to use it, it needs its own copy that belongs to it and can't be read by anybody else. If it thinks the security is lax enough for the key to be stolen, ssh will refuse to operate passwordlessly.

In a root terminal, do this once:

Code:
# Create a safe place for apache to get the key.
mkdir /etc/apache-key
# Make sure it belongs to the web server.
chown apache:apache /etc/apache-key
# Copy the key.
cp /home/username/.ssh/id_rsa /etc/apache-key
# Make it belong to apache and nobody else.
chown apache:apache /etc/apache-key/id_rsa
# Make sure ONLY the apache can read it.
chmod 0400 /etc/apache-key/id_rsa
# Make sure ONLY apache can even get in.
chmod 0700 /etc/apache-key

It might be id_dsa instead of id_rsa, but dsa keys are old now.

Then, in your cgi script, you would run ssh -i /etc/apache-key/id_rsa username@host ls /dir/ and, if everything's where it belongs and has the right permissions, ssh should be able to get in without a password.
# 17  
Old 01-06-2012
buddy i am not sure that i will be able to do these keys operation. So plz give me best commands with little description. i would be very thankful to you.
So after this would i be able to do SCP operation??

---------- Post updated at 12:33 AM ---------- Previous update was at 12:32 AM ----------

yes you are right it is id_dsa .
# 18  
Old 01-06-2012
Quote:
Originally Posted by Navrattan Bansa
buddy i am not sure that i will be able to do these keys operation.
If you don't have root access, it's going to be difficult to get keys with the right permissions. You might have to ask an administrator to do it for you.
Quote:
So after this would i be able to do SCP operation?
Yes, scp is part of ssh and uses the same keys. scp -i /etc/apache-keys/id_dsa ...
# 19  
Old 01-06-2012
i know root password even.?

---------- Post updated at 12:42 AM ---------- Previous update was at 12:40 AM ----------

is my password will be seen by every one ???

And i know root password even i have sudo access also. Can you illustrate Keys process and commands what i have to do on terminal now buddy ?
# 20  
Old 01-06-2012
Quote:
Originally Posted by Navrattan Bansa
is my password will be seen by every one ???
What? No. All you're doing is making the right folders and copying the right files into the right place with the right permissions. You do it once, in private, typing it into a root terminal for your webserver. It's not part of your CGI script, and your CGI script itself never needs root.
Quote:
And i know root password even i have sudo access also. Can you illustrate Keys process and commands what i have to do on terminal now buddy ?
Sure.

Code:
# Create a safe place for apache to get the key.
mkdir /etc/apache-key
# Make sure it belongs to the web server.
chown apache:apache /etc/apache-key
# Copy the key.
cp /home/username/.ssh/id_rsa /etc/apache-key
# Make it belong to apache and nobody else.
chown apache:apache /etc/apache-key/id_rsa
# Make sure ONLY the apache can read it.
chmod 0400 /etc/apache-key/id_rsa
# Make sure ONLY apache can even get in.
chmod 0700 /etc/apache-key

# 21  
Old 01-06-2012
# Make sure it belongs to the web server.
chown apache:apache /etc/apache-key

what is apache here ?? Is It already in my system or i have to create it.

what do u mean it(Make sure it belongs to the web server.)

---------- Post updated at 12:57 AM ---------- Previous update was at 12:55 AM ----------

I will try all these steps . which have told me so i will get back to you. If i will get any error.

I am very thankful 2 u. u spared some time for me.?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl execution commands

I don't know to debug the program todaylive.pl program. plz someone let me know what are the commands I need to know to debug the perl programs to find out the error on it. (3 Replies)
Discussion started by: ramkumar15
3 Replies

2. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

3. Shell Programming and Scripting

Perl cgi pages out of cgi-bin folder in WINDOWS

Hi team, I have a typical problem with cgi pages in apache webserver in WINDOWS I am able to execute(display) the pages that are saved in cgi-bin folder. But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder. Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. 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

5. Web Development

cgi script and external UNIX commands (like swadm)

Hi, I am trying to implement a server monitoring dashboard using cgi scripting. I am planning to run the necessary unix scripts from the web page using cgi. This method works fine for standard unix commands but I am unable to run some external unix commands (like swadm show_processes, swadm... (9 Replies)
Discussion started by: jofinjoseph
9 Replies

6. Shell Programming and Scripting

Execution problem with perl

I got the below error when using the below code...it seem that perl interpret the "'" in the middle and therefore the pipe is not finished. perl -wle ' @a=`who| perl -wlane 'print \$F;' | sort -u` ; chomp @a ; print @a; ' the error message in cygwin is:- perl: No match. | sort... (12 Replies)
Discussion started by: ahmad.diab
12 Replies

7. UNIX Desktop Questions & Answers

CGI execution problem on Unix

Hello everyone, I have developed a cgi application on windows. i have created a folder in webapps of tomcat, within that a WEB-INF folder and in that cgi folder. This cgi folder contains one executable. The web.xml is as follows: <servlet> <servlet-name>cgi</servlet-name> ... (2 Replies)
Discussion started by: Preeti_t
2 Replies

8. Solaris

Solaris 10.5 perl and cron job execution problem

Hi, I want to run a crontab job on solaris 10.5. I have configured the crontab accordingly 10 * * * * /scripts/dbalter.pl >> /scripts/cronout.txt However this does not work .Then I go to /var/mail/root and find an error in the output: From root@myserver Wed Feb 4 17:02:00 2009... (1 Reply)
Discussion started by: sonu2die4
1 Replies

9. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (6 Replies)
Discussion started by: ran16
6 Replies

10. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (0 Replies)
Discussion started by: ran16
0 Replies
Login or Register to Ask a Question