forked from NMSSH/NMSSH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNMSSH.h
103 lines (93 loc) · 3.06 KB
/
NMSSH.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#import <Foundation/Foundation.h>
/**
* NMSSH aims to be a full Objective-C wrapper for libssh2, with an API
* that is easy to understand and fun to work with.
*
* To achieve that goal, the library will assume conventions but still
* make it easy to override them without writing ugly code.
*/
@interface NMSSH : NSObject {
NSString *_host;
NSNumber *_port;
NSString *_username;
NSString *_password;
NSString *_privateKey;
NSString *_publicKey;
}
/**
* Connect to a remote host with username and password
*
* Unless otherwise specified in the host parameter, the port is assumed to be
* 22. To change port, append ":{portnr}" to the hostname.
*
* Examples:
*
* NMSSH *ssh = [NMSSH connectToHost:@"127.0.0.1" withUsername:@"user" password:@"pass" error:&error];
* NMSSH *ssh2 = [NMSSH connectToHost:@"127.0.0.1:4567" withUsername:@"user" password:@"pass" error:&error];
*/
+ (id)connectToHost:(NSString *)host withUsername:(NSString *)username password:(NSString *)password error:(NSError **)error;
/**
* Connect to a remote host with username and public/private key pair
*
* Unless otherwise specified in the host parameter, the port is assumed to be
* 22. To change port, append ":{portnr}" to the hostname.
*
* Examples:
*
* NMSSH *ssh = [NMSSH connectToHost:@"127.0.0.1" withUsername:@"user" publicKey:@"/home/user/.ssh/id_rsa.pub" privateKey:@"/home/user/.ssh/id_rsa" error:&error];
*/
+ (id)connectToHost:(NSString *)host withUsername:(NSString *)username publicKey:(NSString *)publicKey privateKey:(NSString *)privateKey error:(NSError **)error;
/**
* Initialize NMSSH and set its instance variables.
*
* Examples:
*
* NMSSH *ssh = [[NMSSH alloc] initWithHost:@"127.0.0.1" username:@"user" password:@"pass" publicKey:nil privateKey:nil];
*/
- (id)initWithHost:(NSString *)host username:(NSString *)username password:(NSString *)password publicKey:(NSString *)publicKey privateKey:(NSString *)priateKey;
/**
* Connect to a remote host. The return value is a boolean indicating whether or
* not the connection succeded.
*
* Examples:
*
* NSError *error;
* [ssh connect:&error];
*/
- (BOOL)connect:(NSError **)error;
/**
* Disconnect from a remote host
*
* Examples:
*
* [ssh disconnect];
* [ssh release];
*/
- (void)disconnect;
/**
* Execute command in remote shell
*
* Examples:
*
* NSString *response = [ssh execute:@"ls -la" error:&error];
*/
- (NSString *)execute:(NSString *)command error:(NSError **)error;
/**
* Upload a file to the remote server via SCP.
*
* Examples:
*
* NSError *error;
* BOOL success = [ssh uploadFile:@"/path/to/local.txt" to:@"/path/to/remote.txt" error:&error];
*/
- (BOOL)uploadFile:(NSString *)localPath to:(NSString *)remotePath error:(NSError **)error;
/**
* Request a file from the remote server via SCP.
*
* Examples:
*
* NSError *error;
* BOOL success = [ssh downloadFile:@"/path/to/remote.txt" to:@"/path/to/local.txt" error:&error];
*/
- (BOOL)downloadFile:(NSString *)remotePath to:(NSString *)localPath error:(NSError **)error;
@end