From 1211b8b7a54fd3bcc917d2ed385246ab5cd2799a Mon Sep 17 00:00:00 2001 From: Thomas Evensen <thomeven@gmail.com> Date: Wed, 14 Aug 2024 19:48:22 +0200 Subject: [PATCH] update --- Sources/SSHCreateKey/SSHCreateKey.swift | 10 ++++++---- Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Sources/SSHCreateKey/SSHCreateKey.swift b/Sources/SSHCreateKey/SSHCreateKey.swift index fa5f446..e2fee46 100644 --- a/Sources/SSHCreateKey/SSHCreateKey.swift +++ b/Sources/SSHCreateKey/SSHCreateKey.swift @@ -28,7 +28,7 @@ public final class SSHCreateKey { return nil } - // Path to ssh keypath + // Path to ssh keypath including identityfile public var sshkeypathandidentityfile: String? { if let sharedsshkeypathandidentityfile, let userHomeDirectoryPath @@ -39,16 +39,16 @@ public final class SSHCreateKey { let sshkeypathandidentityfilesplit = sharedsshkeypathandidentityfile.split(separator: "/") guard sshkeypathandidentityfilesplit.count > 2 else { // If anything goes wrong set to default global values - return userHomeDirectoryPath + "/.ssh" + return userHomeDirectoryPath + "/.ssh/" + "/" + (identityfile ?? "") } return userHomeDirectoryPath + sshkeypathandidentityfilesplit.joined(separator: "/").dropFirst() } else { // If anything goes wrong set to default global values - return userHomeDirectoryPath + "/.ssh" + return userHomeDirectoryPath + "/.ssh" + "/" + (identityfile ?? "") } } else { - return (userHomeDirectoryPath ?? "") + "/.ssh" + return (userHomeDirectoryPath ?? "") + "/.ssh" + "/" + (identityfile ?? "") } } @@ -159,6 +159,8 @@ public final class SSHCreateKey { args.append(sharedsshkeypathandidentityfile) args.append("-p") args.append(sharedsshport) + } else { + args.append(identityfile ?? "") } args.append(offsiteUsername + "@" + offsiteServer) return args.joined(separator: " ") diff --git a/Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift b/Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift index 7253190..f447f39 100644 --- a/Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift +++ b/Tests/SSHCreateKeyTests/SSHCreateKeyTests.swift @@ -19,6 +19,8 @@ import Testing print(arg4 ?? "") let arg5 = await sshcreatekey.userHomeDirectoryPath print(arg5 ?? "") + let arg6 = await sshcreatekey.sshkeypathandidentityfile + print(arg6 ?? "") } } @@ -39,6 +41,8 @@ import Testing print(arg4 ?? "") let arg5 = await sshcreatekey.userHomeDirectoryPath print(arg5 ?? "") + let arg6 = await sshcreatekey.sshkeypathandidentityfile + print(arg6 ?? "") } } -- GitLab