diff --git a/Sources/SSHCreateKey/SSHCreateKey.swift b/Sources/SSHCreateKey/SSHCreateKey.swift
index fa5f4464b1a541851a77a115eff47eaf5e38aa9c..e2fee463c84a16a346ea9f430dafabb0f9078f20 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 72531902120be747b7075b523173d327ada57ff2..f447f3951cb164554c366f89fea0a19721210939 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 ?? "")
         }
     }