[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

free SFTP library

Posted on 2004-03-31
8
Medium Priority
?
1,373 Views
Last Modified: 2007-12-19
Hello,

Can anyone recomend a good, free SFTP (secure ftp) library in C or C++ or (best even if... unlikely) Tcl?

Thanks
0
Comment
Question by:s_federici
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 10724004
Hi s_federici,


Sure.  Start with openssh.  You can get to their source code via www.openssh.com



Kent
0
 
LVL 24

Accepted Solution

by:
fridom earned 1000 total points
ID: 10724682
You might want to check libcurl from
http://curl.haxx.se/libcurl/

Regards
Friedrich
0
 

Author Comment

by:s_federici
ID: 10725002
Friedrich,
libcurl seems EXACTLY what I need. It is only a little obscure (maybe due to the fact that I only took a look at it) how I can use it to perform secure ftp. But the Tcl bindings are there.

Before I can assign you the points I need to spend some time to see if it will work for me or (if you will be so kind) maybe you can send me a few examples or pointers to them.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

by:anupvijay
ID: 10725429
Hi federici,

Just got another link for you. Might be helpful.

http://www.chiark.greenend.org.uk/~sgtatham/putty/

Cheers,
Anup
0
 

Author Comment

by:s_federici
ID: 10726872
As far as I understand, putty is a command line interface, not a library. I have to realize an SFTP connection programmatically with password and without supervision. And if I correctly understood, with putty I should interact with a shell to insert the password. Am I wrong? If so, please send me an example of usage.
0
 
LVL 24

Expert Comment

by:fridom
ID: 10732014
Well libcurl has probalbly the easiest interface to understand.  here's an example fetching a page with HTTP:
static int fetch_simple_page (CURL *curl){
      CURLcode res;
      char err_buf [2* CURL_ERROR_SIZE];
      char simple_text_url [] = "http://localhost/~frido/libcurl-examples/simple.txt";
      res = curl_easy_setopt(curl, CURLOPT_URL, simple_text_url);
      if (CURLE_OK != res){
            goto error;
      }
      res = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, err_buf);
      if (CURLE_OK != res){
            goto error;
      }
      res = curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, my_fwrite);
      if (CURLE_OK != res){
            goto error;
      }
      res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, &my_file);
      res = curl_easy_perform(curl);
      if (CURLE_OK != res){
            goto error;
      }
    return 1;
      error:
            fprintf(stderr, "curl error: %s\n", err_buf);
            return 0;

}

Well the base line is: You initailize the library, you set some options, in first line what URL you want to fetch, what write function you want to use (you can e.g write to memory mapped files, or "normal" files, do as you like) then you say ..._perform and the page is fetched.

Here's a complete example of an FTP download (without error handling this time, it shows how a user and password can be sent. AFAIK does it work for SFTP too.
#include <stdio.h>
#include <curl/curl.h>



static int fetch_simple_page (CURL *curl){
      CURLcode res;
    FILE *my_file = fopen("LCC_README", "w");
      char simple_text_url [] = "ftp://ftp:someone.somwhere@www.q-software-solutions.com/pub/lcc/README";
      res = curl_easy_setopt(curl, CURLOPT_URL, simple_text_url);
    res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
    // res = curl_easy_setopt(curl, CURLOPT_VERBOSE);
      res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, my_file);
      res = curl_easy_perform(curl);
    fclose(my_file);
    return 1;
}


int main(void)
{
  CURL *curl;
  int irval = 0;


  curl = curl_easy_init();
  if(curl) {
    irval = fetch_simple_page(curl);
      if (irval){
      puts("Got the page");
       }


    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  curl_global_cleanup();
  return 0;
}

You may want to visit http://curl.haxx.se/libcurl if you need assitance with libcurl development. Well if you like you can find out my address and I'll see what I can do for you.

Regards
Friedrich

0
 
LVL 24

Expert Comment

by:fridom
ID: 10732027
Well a sort of follow-up, you can use pscp or scp or rsync for copying files it takes username etc but that's a command line tool, if you want to use such a thing you might want to check curl and wget too.

Regards
Friedrich
0
 

Author Comment

by:s_federici
ID: 10732406
I'm definitely going to try libcurl (in the Tcl version I think). In the meantime I'm going to assign to you the full points (the command line tools suggested in the other answers are not what I was looking for). Please, allow me to bother you with some follow ups if I'm in trouble with it.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question