views:

113

answers:

3

I have an app that needs to run a command in the terminal. or i want to run this command in my app.

ssh -N -p 24 -g -D 1080 username@server

plz help me . tnx

+1  A: 

Your comment is the solution to your question ;)

hhafez
tnx.but this command will ask for password . then how to enter password? any solution ?
Naeim
Set up ssh keys so that you don't need a password ?
Paul R
+3  A: 

Try ssh keys. Check out ssh-keygen for more information. Simply generate a key for yourself, put the public key (usually ~/.ssh/id_rsa.pub) in a file called ~/.ssh/authorized_keys on the box you want to ssh into, and voila, it should just work :)

saramah
Just noticed that you're doing this in relation to an iPhone app (at least from the tags you've posted); I'm not certain this will work if you're trying to ssh from an iPhone to a server. You might want to explore alternatives to getting your information to the phone, perhaps by getting your app to query the server for information rather than getting the client to root around on the server.
saramah
+3  A: 

You've marked this question as iphone and iphone-sdk, but it's not possible to fork or exec in an App Store application. If you need SSH connectivity for your application, you can use a library like libssh2, but you won't be able to reuse the standard ssh command.

rpetrich