How to use libssh in a project



  • Dear Qties,

    I am very new to developing with Qt and C++, however for a school project I am required to make a dashboard application. It should be able to connect to a remote host and send commands over ssh and read the responses.

    Through googling I have found that it would be best to use the libssh library to achieve this. I am too inexperienced to know how to import this library into my project and googling isn't helping me out. I am currently working on a Mac but the application should also be able to run on Ubuntu. Can anyone help me out by listing the steps required to use the library? Or maybe you know of a better way to implement this kind of functionality?

    Thanks in advance,

    Kind Regards Valveware


  • Qt Champions 2017

    Hi and Welcome
    Maybe this helps
    https://forum.qt.io/topic/64367/integration-of-libssh-into-a-qt-project

    THe key is
    LIBS += -L$$PWD/LibSSH/lib -lssh

    which tells it where to look for the DLL.

    On mac or Ubunto it might be a .SO file, not dll but idea is the same.

    [edit: fixed linker option SGaist]



  • @mrjj
    When I downloaded the libssh files from their website it doesn't include a .dll or an .SO file. Where should I be getting these?


  • Qt Champions 2017

    @Valveware said in How to use libssh in a project:

    @mrjj
    When I downloaded the libssh files from their website it doesn't include a .dll or an .SO file. Where should I be getting these?

    I guess you fetched the source code. you will get the binaries by compiling the sources ;)

    Honestly, either compile the sources yourself or use Google to find suitable binaries for your OS and your compiler.


  • Qt Champions 2017

    @Valveware: I just read about your Ubuntu requirement.

    For this OS the libssh library and header files can be installed by running

    sudo apt-get install libssh-dev

    in a Terminal.



  • Thanks for the replies however I am still stuck with my problem. I have decided to not try to make libssh work. So i was looking into Qssh (https://github.com/lvklabs/QSsh). I managed to download this and qmake it. But then when making it complains saying fatal error: 'botan/mode_pad.h' file not found. When opening the example in qt and trying to build it says 'library not found for -lbotan2' thus the linker fails. I got the idea that botan should be in the qt library so why can't it find this?

    Another question is, I found an example for ssh usage in the qt-creator library. But how can i make qt understand where to find #include "sshconnection.h" ?( https://github.com/danimo/qt-creator/blob/master/src/libs/ssh/sshconnection.h )



  • I have managed to solve my initial problem. I have now been able to include the libssh library. Thanks a lot for the help, I know these are dumb questions but hey , I'm learning. If you can I'd still like an answer to my last reply just to know how or why but right now I can continue on my application trying to set up ssh to send commands.


  • Lifetime Qt Champion

    Hi,

    For botan, no it's a dependency that you have to install. By the way, QSsh is not an official Qt module, what the author did was to take out of Qt Creator the implementation of ssh and sftp connection and make an independent library out of it.

    As for your last question, the same as you would for any other library however you'll have to also find the corresponding library to link against.



  • I think you need to give us the actual problem. Where are you stuck?

    • install libssh (you've done that)
    • Include the header file
    • compile it in (Have you done that? someone explained how to link it, did you add the "INCLUDEPATH += ..."?
    • Use the API.

    If this is a programming class, then using the API is all on you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.