Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

Libssh2 at FSCONS 2009

  1. FSCONS Göteborg, November 14 th 2009
  2. Consultant at Haxx
  3. Open Source since 15 years
  4. Contributed to 20+ projects
  5. 15K public commits
  6. cURL, Rockbox etc
  7. Questions Please do interrupt and ask if you have questions!
  8. Background
  9. Why a lib is needed
  10. The project
  11. App examples
  12. Competitors
  13. Future
  14. Contributors
  15. On top of TCP/IP
  16. Invented by Tatu Ylönen in 1995
  17. OpenSSH 1999
  18. Internet Standard 2002, RFC4251 and friends
  19. SSH is not SSL but similarities exist
  20.  
  21. A little story Once upon a time...
  22. 1997 Wouldn't it be nice with a tool that grabs HTTP?
  23. 1998 Wouldn't it be nice if it did FTP too?
  24. 1999 And Gopher!
  25. 1999 Wouldn't it be nice if it did HTTPS too?
  26. 2000 You get the picture. Time moved on. It was now also a lib
  27. 2006 Supporting HTTP, HTTPS, FTP, FTPS, TELNET, LDAP, LDAPS, DICT, TFTP and FILE. Using several underlying libraries. Wouldn't it be nice if it did SCP and SFTP too?
  28. Putty – no lib
  29. Libssh (license, blocking, thread-safety...)
  30. Libssh2 – there you go
  31. Embeddable, command line tools aren't enough
  32. Portability – not limited to POSIX (C89)
  33. Use SSH for SSL-like stuff
  34. License – as free as possible
  35. Only 20K LOC
  36. Client and server
  37. SSH2 only (no v1)
  38. For PHP
  39. Sara set the API, made it run
  40. Daniel entered Nov 2006
  41. For libcurl (non-blocking!)
  42. Client-side only (for simplicity)
  43. Plain ANSI C89 C
  44. Low key
  45. Mailing list driven
  46. Meritocracy
  47. Start-up feeling
  48. Not many users (apps)
  49. git
  50. Individual copyrights
  51. No umbrella org
  52. Channels
  53. SCP
  54. X11
  55. SFTP
  56. Publickey
  57. pass in socket
  58. external poll()
  59. Crypto-layer abstracted
  60. Knownhost
  61. Blocking API SCP client /* create a socket */ sockfd = socket(); /* connect to server */ connect(sockfd, address); /* get a libssh2 session handle (blocking behavior is default) */ session = libssh2_session_init(); /* pass in the socket to the SSH2 session */ libssh2_session_startup(session, sockfd); /* password authentication (known host handling skipped) */ libssh2_userauth_password(session, username, password)); /* request a file with SCP */ channel = libssh2_scp_recv(session, “/home/daniel/textfile”, &fileinfo); while (!done) libssh2_channel_read(channel, mem, amount); /* free the SCP channel */ libssh2_channel_free(channel); /* disconnect session */ libssh2_session_disconnect(session, "shutdown”); /* free the session */ libssh2_session_free(session); /* close the socket */ close(socket);
  62. /* create a socket */ sockfd = socket(); /* connect to server */ connect(sockfd, address); /* get a libssh2 session handle (blocking behavior is default) */ session = libssh2_session_init(); /* pass in the socket to the SSH2 session */ libssh2_session_startup(session, sockfd); /* password authentication (known host handling skipped) */ libssh2_userauth_password(session, username, password)); /* request a file with SCP */ channel = libssh2_scp_recv(session, “/home/daniel/textfile”, &fileinfo); while (!done) libssh2_channel_read(channel, mem, amount); /* free the SCP channel */ libssh2_channel_free(channel); /* disconnect session */ libssh2_session_disconnect(session, "shutdown”); /* free the session */ libssh2_session_free(session); /* close the socket */ close(socket); Blocking API SFTP client /* create the SFTP session */ sftp_session = libssh2_sftp_init(session); sftp_handle = libssh2_sftp_open(sftp_session, “/home/daniel/file”, LIBSSH2_FXF_READ, 0); while (!done) libssh2_sftp_read(sftp_handle, mem, amount); /* close the SFTP handle */ libssh2_sftp_close(sftp_handle); /* close the SFTP session */ libssh2_sftp_shutdown(sftp_session);
  63. Or use libcurl! Libcurl supports SCP and SFTP URLs http://curl.haxx.se/
  64. Feature wise?
  65. Bug and stability wise?
  66. Free for virtually every use
  67. Sara G picked it
  68. Suitable for re-use by other libs/platforms
  69. License
  70. non-blocking
  71. Name-space polluting
  72. Commercial?
  73. Me
  74. Simon J
  75. A few other happy campers
  76. No particular company backing
  77. Company-funded features
  78. Make more stable
  79. Improve speed (esp SFTP)
  80. Use less mallocs
  81. Use less memory (adjust windows etc)
  82. Missing features?
  83. Scratch itches
  84. Written in C
  85. The best one available
  86. Small team
  87. www.libssh2.org
  88. Join in! libssh2 needs you!

Editor's Notes

  1. Commits counted by ohloh c-ares, Subversion
  2. SSH v1 is deemed insecure and is widely abandoned anyway
  3. Libssh2 supports the different layers
  4. Gcrypt or OpenSSL Knownhost works with OpenSSH style knownhost files
  5. See how its almost the same, just a little extra cruft added for SFTP instead of SCP.
  6. An additional abstraction layer. Most useful if you deal with more than one protocol, or perhaps if you want to work easily with many parallell transfers with ease.
  7. SCP speed is on par with OpenSSH SFTP speed is lesser than OpenSSH due to protocol complexity and how the libssh2 API works and the work needed to fix it. Faster than libssh still Features wise, it offers a lot. Bug wise it is fairly stable and solid, even if there still are bugs appearing that need to be fixed. Several existing commercial applications are relying on libssh2.
  8. BSD without advertising clause
  9. Libssh is LGPL
  10. Like most projects, this never ends
  11. We need your help
Advertisement