I'm working on a iOS app which will take some inputs from user and send it to server using SSH and server acknowledges. Sending is working fine, however unable to implement listening from server side.
NMSSHSession *session = [NMSSHSession connectToHost:@"127.0.0.1:22"
withUsername:@"user"];
if (session.isConnected) {
[session authenticateByPassword:@"pass"];
if (session.isAuthorized) {
NSLog(@"Authentication succeeded");
}
}
NSError *error = nil;
NSString *response = [session.channel execute:@"ls -l /var/www/" error:&error];
NSLog(@"List of my sites: %@", response);
BOOL success = [session.channel uploadFile:@"~/index.html" to:@"/var/www/9muses.se/"];
[session disconnect]; //of course I want to keep the connection on all the time.
A post on SO Stream of data through NMSSH got resolved using NMSSH shell which lead to [NMSSH Issue 20] however, but it did not help in my case.
I've seen very little tutorials and help available on this library implementation, not getting quite a right direction.
The following response from NMSSH Library Team. I've just tried and it's working, I'll update my answer related to other queries.
NMSSH on GitHub (Issue No. 143) section also have lot of resources to explore on this library.
The methods of NMSSHChannelDelegate are called when the channel is in shell mode (see startShell:) but the method execute:error: use the channel in command mode. session:didDisconnectWithError: is not called because you don't disconnect the session. Please note that session will be released at the end of serverConnect:, you should store the session in a property of CustomViewController.
My feedback below inline.
I used AsyncAPI another branch of NMSSH and works asynchronously to send or receive data, specially sending multiple commands is seamless now.