tags:

views:

62

answers:

2

Hi all, I am writing a programing (in C) in which I have to access data from another computer through an SSH connection. I was wondering how to create the SSH connection within the program.

Thanks

+3  A: 

Have a look at libssh. Have you attempted to look for an answer yourself? Have you tried using some libraries and haven't got them working?

It is always best to try to help yourself before looking for handouts. YMMV.

Dan McGrath
Answers on Stack Overflow are handouts? That was a little harsh.
Tim Post
When no prior attempt at finding the information that is widely (and easily) found, yes. Same as when you are at work or anywhere else in real life, at least make an attempt to find the information before asking for someone else to give it to you (aka, asking for a handout).
Dan McGrath
+1  A: 

One easy solution would be to use the ssh binary and call that from your program. Create 3 pipes using pipe(), then fork(), close() the appropriate endpoints (not sure if that's needed) so you have 2 processes with 3 pipes between them. On the child, dup2() the pipe endpoints to stdin, stdout and stderr (i.e. fd's 0, 1, 2) and exec() the ssh command.

On the parent process you can now just talk to the other side. Use RSA authentication to get rid of password stuff.

But there may be libraries to just connect, I don't know ;-)

mvds
(or should I have used the <irony> tag here for clarity?)
mvds
lol ;-) as much as I like this, I don't think it should be the top answer.
David Zaslavsky
I can tell you, to figure this out myself, in the early '00s, took considerably longer than a 9 minute wait on SO... ;-)
mvds