Thread: Client Socket Program to connect to SSH Server

  1. #1
    Registered User
    Join Date
    Dec 2016
    Posts
    6

    Client Socket Program to connect to SSH Server

    I have a SSH server asking for username and password for authentication and i am writing a client C program in linux only using socket or standard function. Once I created a socket using SSH server's IP and port, how to authenticate user with server? Thank you.

  2. #2
    Registered User
    Join Date
    Dec 2016
    Posts
    6

    libssh library: undefined reference to `ssh_new' error

    how to format the question properly...please help................I am trying to write a SSH program using libssh library. I am at beginner level in C language.
    Code:
      #include  #include  #include   int main() {     ssh_session my_ssh_session = ssh_new();\n     if (my_ssh_session == NULL)         exit(-1);     printf("done!");     ssh_free(my_ssh_session);    }
    And on compiling, this is the error that i got,
    Code:
     ubuntu@ubuntu:~/Desktop/SSH$ gcc -o test test.c  /tmp/ccw8Zq99.o: In function `main': test.c:(.text+0x9): undefined reference to `ssh_new' test.c:(.text+0x39): undefined reference to `ssh_free' collect2: error: ld returned 1 exit status
    On googling a little, i come across this link, so..
    Code:
     ubuntu@ubuntu:~/Desktop/SSH$ gcc -lssh -o test test.c  /usr/bin/ld: cannot find -lssh collect2: error: ld returned 1 exit status
    I think i have made some mistake while adding libssh.h header file. this is what i have done is 1. install tar file from official website 2. extract it 3. copy libssh/ folder present in include folder to /usr/include. That's it. Is this the correct way to add a header file? Any kind of help/sugestion is appreciated. Thank you. Can somebody please tell me how to format the question?
    Last edited by emmaclark; 12-26-2016 at 01:34 AM.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    30

    libssh library

    Did you install libssh and libssh-dev? You are getting linker error which means you have not installed the ssh library.

  4. #4
    Registered User
    Join Date
    Dec 2016
    Posts
    6
    I tried to install it using apt-get in ubuntu, but i am getting an "unmet dependency" error. So i downloaded the tar package from libssh official website. Extract it and copy include folder in /usr/include. Is this the correct way to install libssh?

  5. #5
    Registered User
    Join Date
    Nov 2008
    Posts
    30
    Most libraries have two components - actual library object files, and their headers. You copied the headers to /usr/include. You need to copy the library files, which are generated when you build. Instead of manually copying all these files (including headers), you can follow the instructions in "INSTALL" file of the libssh source about how to build and install the library.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Socket Program to connect to SSH server
    By emmaclark in forum C Programming
    Replies: 2
    Last Post: 12-23-2016, 08:35 AM
  2. Replies: 29
    Last Post: 10-22-2009, 11:01 AM
  3. Problem with simple socket client/server program
    By spencer88 in forum C Programming
    Replies: 6
    Last Post: 05-05-2009, 11:05 PM
  4. Client/server won't connect
    By Lateralus in forum Networking/Device Communication
    Replies: 0
    Last Post: 06-15-2005, 07:48 AM
  5. Getting info on a client when they connect to the server
    By Finchie_88 in forum Networking/Device Communication
    Replies: 4
    Last Post: 06-01-2005, 07:12 AM

Tags for this Thread