Programmer_10 [3:16 PM]
How to create a new ssh session?

Apiza [3:17 PM]
To  create a new session, use ssh_new with signature ssh_session ssh_new()


Programmer_10 [3:18 PM]
what is the signature?

Apiza [3:18 PM]
The method signature explains how to call the method

Programmer_10 [3:19 PM]
what parameters has the method ssh_new()?

Apiza [3:20 PM]
There are no parameters for ssh_new

Programmer_10 [3:20 PM]
what type of values does it return?

Apiza [3:21 PM]
ssh_new return ssh_session or NULL on error.

Programmer_10 [3:26 PM]
How to connect to the server?

Apiza [3:26 PM]
To connect to the ssh server, use ssh_connect

Programmer_10 [3:27 PM]
is ssh_connect a function?

Apiza [3:28 PM]
yes

Programmer_10 [3:28 PM]
what parameters does it take?

Apiza [3:28 PM]
It takes in one parameter: a session with data type ssh_session
The method signature is int ssh_connect(ssh_session session)

Programmer_10 [3:29 PM]
what value does it return?
ok iunderstand
how to specify the exact server i want to connect to?

Apiza [3:30 PM]
You can use the method ssh_options_set for that
The method signature is int ssh_options_set(ssh_session session, enum ssh_options_e type, const void * value)

Programmer_10 [3:32 PM]
what is the relationship between ssh_connect and ssh_options?

Apiza [3:33 PM]
ssh_options_set is a function that can set all possible ssh options
The enum ssh_options_e can be values such as SSH_OPTIONS_HOST and SSH_OPTIONS_PORT

Programmer_10 [3:34 PM]
is ssh_options enough by itself to connect to the server?
or i should use it first then use ssh_connect?

Apiza [3:35 PM]
The method ssh_options_set sets the options.

Programmer_10 [3:36 PM]
the right order is ssh_options then ssh_connect, right?

Apiza [3:37 PM]
I'm sorry, I'm only able to respond to API questions

Programmer_10 [3:37 PM]
what is the third parameter in ssh_options?

Apiza [3:38 PM]
value: The value to set. This is a generic pointer and the datatype which is used should be set according to the type set.

Programmer_10 [3:40 PM]
how to connect to the local host?

Apiza [3:40 PM]
To connect to the ssh server, use ssh_connect

Programmer_10 [3:44 PM]
how to authenticate the server?

Apiza [3:45 PM]
There are many different types of authentication, would you like me to list them?

Programmer_10 [3:45 PM]
yes

Apiza [3:45 PM]
ssh_userauth_agent
ssh_userauth_gssapi
ssh_userauth_kbdint
ssh_userauth_kbdint_getanswer
ssh_userauth_kbdint_getinstruction
ssh_userauth_kbdint_getname
ssh_userauth_kbdint_getnanswers
ssh_userauth_kbdint_getnprompts
ssh_userauth_kbdint_getprompt
ssh_userauth_kbdint_setanswer
ssh_userauth_list
ssh_userauth_none
ssh_userauth_password
ssh_userauth_publickey
ssh_userauth_publickey_auto
ssh_userauth_try_publickey

Programmer_10 [3:47 PM]
what is the method for server authentication?

Apiza [3:47 PM]
There are many ways to authenticate, they are listed above

Programmer_10 [3:48 PM]
what does ssh_userauth_agent do?

Apiza [3:48 PM]
ssh_userauth_agent is used to try to do public key authentication with ssh agent

Programmer_10 [3:49 PM]
what is server authentication?

Apiza [3:49 PM]
There are many ways to authenticate, they are listed above

Programmer_10 [3:52 PM]
authenticating ssh server?

Apiza [3:52 PM]
There are many different types of authentication, would you like me to list them?

Programmer_10 [3:55 PM]
how to authenticate the user?

Apiza [3:56 PM]
Authentication can be performed with one of the following methods:
ssh_userauth_agent
ssh_userauth_gssapi
ssh_userauth_kbdint
ssh_userauth_kbdint_getanswer
ssh_userauth_kbdint_getinstruction
ssh_userauth_kbdint_getname
ssh_userauth_kbdint_getnanswers
ssh_userauth_kbdint_getnprompts
ssh_userauth_kbdint_getprompt
ssh_userauth_kbdint_setanswer
ssh_userauth_list
ssh_userauth_none
ssh_userauth_password
ssh_userauth_publickey
ssh_userauth_publickey_auto
ssh_userauth_try_publickey
Would you like to know more about one?

Programmer_10 [3:57 PM]
ssh_userauth_none

Apiza [3:58 PM]
ssh_userauth_none method tries to authenticate through the "none" method

Programmer_10 [3:58 PM]
what is the "none" method?

Apiza [3:59 PM]
The none method does not perform any authentication

Programmer_10 [4:00 PM]
what is the signature of ssh_userauth_agent?

Apiza [4:00 PM]
The signature is ssh_userauth_agent (ssh_session session, const char * username)
The signature is int ssh_userauth_agent (ssh_session session, const char * username)

Programmer_10 [4:01 PM]
what is the signature of ssh_userauth_gssapi?

Apiza [4:01 PM]
The signature is int ssh_userauth_gssapi (ssh_session session)

Programmer_10 [4:02 PM]
what does the method ssh_userauth_gssapi do?

Apiza [4:02 PM]
ssh_userauth_gssapi method tries to authenticate through the "gssapi-with-mic" method

Programmer_10 [4:03 PM]
what is the "gssapi-with-mic"?

Apiza [4:03 PM]
I'm sorry, I can only answer API questions

Programmer_10 [4:03 PM]
how to know i connected to the server?

Apiza [4:05 PM]
ssh_connect returns an integer representing the status of the action: SSH_OK on success, SSH_ERROR on error.
SSH_AGAIN, if the session is in nonblocking mode, and call must be done again.

Programmer_10 [4:11 PM]
what does -1 means as a return value of ssh_connect?

Apiza [4:11 PM]
ssh_connect returns an integer representing the status of the action: SSH_OK on success, SSH_ERROR on error.
SSH_AGAIN, if the session is in nonblocking mode, and call must be done again.

Programmer_10 [4:12 PM]
how to call ssh_userauth_password?

Apiza [4:13 PM]
The signature is int ssh_userauth_password(ssh_session session, const char * username, const char * password)

Programmer_10 [4:13 PM]
and the return value?

Apiza [4:13 PM]
Returns:
SSH_AUTH_ERROR: A serious error happened.
SSH_AUTH_DENIED: Authentication failed: use another method
SSH_AUTH_PARTIAL: You've been partially authenticated, you still have to use another method
SSH_AUTH_SUCCESS: Authentication success
SSH_AUTH_AGAIN: In nonblocking mode, you've got to call this again later.
Note
Most server implementations do not permit changing the username during authentication. The username should only be set with ssh_options_set() only before you connect to the server.

Programmer_10 [4:15 PM]
how to set the username in ssh_options_set()?

Apiza [4:16 PM]
ssh_options_set takes in an enum ssh_options_e. One of the values of that enum is SSH_OPTIONS_USER

Programmer_10 [4:17 PM]
what should be the value for SSH_OPTIONS_USER>
?

Apiza [4:18 PM]
SSH_OPTIONS_USER: The username for authentication (const char *).

If the value is NULL, the username is set to the default username.

Programmer_10 [4:24 PM]
how to disconnect from the server?

Apiza [4:26 PM]
To disconnect, use ssh_disconnect with signature: void ssh_disconnect(ssh_session session)

Programmer_10 [4:27 PM]
what value does it return?

Apiza [4:27 PM]
It does not return a value

Programmer_10 [4:30 PM]
how to open a new ssh session?

Apiza [4:31 PM]
To create a new ssh session, use ssh_new

Programmer_10 [4:32 PM]
how to execute a command in the channel?

Apiza [4:32 PM]
To run a shell command without an interactive shell, use ssh_channel_request_exec
This is similar to 'sh -c command'

Programmer_10 [4:33 PM]
what is the signature of ssh_channel_request_exec?

Apiza [4:34 PM]
int ssh_channel_request_exec ( ssh_channel channel, const char * cmd )