aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPSSHTunnel.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPSSHTunnel.m')
-rw-r--r--Source/SPSSHTunnel.m19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m
index 5cc833fd..807d507e 100644
--- a/Source/SPSSHTunnel.m
+++ b/Source/SPSSHTunnel.m
@@ -72,6 +72,7 @@
}
parentWindow = nil;
+ identityFilePath = nil;
sshQuestionDialog = nil;
sshPasswordDialog = nil;
password = nil;
@@ -128,6 +129,19 @@
return YES;
}
+/**
+ * Sets the path of an identity file, or public key file, to use when connecting.
+ */
+- (BOOL) setKeyFilePath:(NSString *)thePath
+{
+ NSString *expandedPath = [thePath stringByExpandingTildeInPath];
+ if (![[NSFileManager defaultManager] fileExistsAtPath:expandedPath]) return NO;
+
+ if (identityFilePath) [identityFilePath release];
+ identityFilePath = [[NSString alloc] initWithString:expandedPath];
+ return YES;
+}
+
/*
* Sets the keychain name to use to retrieve the password. This is the recommended and
* secure way of supplying a password to the SSH tunnel.
@@ -282,6 +296,10 @@
[taskArguments addObject:@"-o ExitOnForwardFailure=yes"];
[taskArguments addObject:[NSString stringWithFormat:@"-o ConnectTimeout=%ld", (long)connectionTimeout]];
[taskArguments addObject:@"-o NumberOfPasswordPrompts=3"];
+ if (identityFilePath) {
+ [taskArguments addObject:@"-i"];
+ [taskArguments addObject:identityFilePath];
+ }
if (useKeepAlive && keepAliveInterval) {
[taskArguments addObject:@"-o TCPKeepAlive=no"];
[taskArguments addObject:[NSString stringWithFormat:@"-o ServerAliveInterval=%ld", (long)ceil(keepAliveInterval)]];
@@ -652,6 +670,7 @@
if (password) [password release];
if (keychainName) [keychainName release];
if (keychainAccount) [keychainAccount release];
+ if (identityFilePath) [identityFilePath release];
// As this object is not a NSWindowController, use manual top-level nib item management
if (sshQuestionDialog) [sshQuestionDialog release], sshQuestionDialog = nil;