[LCP]system funtion or fork or exec
Greg Black
gjb at gbch.net
Sat Feb 8 08:02:26 UTC 2003
"Gonzalo Sanchez" wrote:
(Please limit your lines to about 70 characters -- the long
lines are irritating and I have re-formatted them.)
| Hi I am new in the linux world. I've been trying to execute
| the system function to execute the following code:
|
| uid = geteuid();
| return_value = system("ssh -N -f -L 7050:rmyserver:6565 myUser at myserver\n");
|
| The code works fine. The problem with this is that I need to
| type my password to authenticate. If everything goes well
| then I have a ssh tunnel with port 7050 listening from 6565
| from myserver.
|
| I would like to know how can you append the password to
| return_value so that I dont have to type the password, since
| this routine has to be automatic.
|
| Please advice if there is any other better form to do it...or
| how append the password (of course that is not too secure)
Using system() is just a way of running a shell program from
within a C program and issues with it are shell programming
issues, not C programming issues. In this case, the problem is
that you have not read the ssh manuals properly.
Read about the ssh-agent program and your problem will be easy
to solve.
Greg
More information about the linuxCprogramming
mailing list