From 4e2c47f09a75d393fe8eb52f5e9a196752adb8ba Mon Sep 17 00:00:00 2001
From: neon443 <69979447+neon443@users.noreply.github.com>
Date: Thu, 5 Jun 2025 12:46:42 +0100
Subject: [PATCH] using blink shell's ssh for ssh instead of nmsssh idk why it
doesnt work
---
.../PTYExample.xcodeproj/project.pbxproj | 10 ++-
.../PTYExample/PTYExample-Info.plist | 7 ++
ShhShell.xcodeproj/project.pbxproj | 62 ++++++++++++-
.../xcshareddata/swiftpm/Package.resolved | 87 +++++++++++++++++++
ShhShell/SSHHandler.swift | 55 ++++++++++++
ShhShell/ShellHandler.swift | 26 ++++++
ShhShell/Views/ContentView.swift | 7 +-
7 files changed, 249 insertions(+), 5 deletions(-)
create mode 100644 ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
create mode 100644 ShhShell/SSHHandler.swift
create mode 100644 ShhShell/ShellHandler.swift
diff --git a/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample.xcodeproj/project.pbxproj b/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample.xcodeproj/project.pbxproj
index 46251e3..76cccb7 100644
--- a/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample.xcodeproj/project.pbxproj
+++ b/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample.xcodeproj/project.pbxproj
@@ -168,12 +168,18 @@
CLASSPREFIX = NM;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = "Nine Muses";
+ TargetAttributes = {
+ 18AE8FA418BBEDD000AE0FC3 = {
+ DevelopmentTeam = 8JGND254B7;
+ };
+ };
};
buildConfigurationList = 18AE8FA018BBEDD000AE0FC3 /* Build configuration list for PBXProject "PTYExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
+ English,
en,
Base,
);
@@ -321,7 +327,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
- DEVELOPMENT_TEAM = "";
+ DEVELOPMENT_TEAM = 8JGND254B7;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PTYExample/PTYExample-Prefix.pch";
INFOPLIST_FILE = "PTYExample/PTYExample-Info.plist";
@@ -337,7 +343,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
- DEVELOPMENT_TEAM = "";
+ DEVELOPMENT_TEAM = 8JGND254B7;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PTYExample/PTYExample-Prefix.pch";
INFOPLIST_FILE = "PTYExample/PTYExample-Info.plist";
diff --git a/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample/PTYExample-Info.plist b/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample/PTYExample-Info.plist
index 9e81407..5f5b5c2 100644
--- a/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample/PTYExample-Info.plist
+++ b/Carthage/Checkouts/NMSSH/Examples/PTYExample/PTYExample/PTYExample-Info.plist
@@ -24,6 +24,13 @@
1.0
LSRequiresIPhoneOS
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+ NSAllowsLocalNetworking
+
+
UILaunchStoryboardName
Launch Screen
UIMainStoryboardFile
diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj
index 952539c..e4ad0cf 100644
--- a/ShhShell.xcodeproj/project.pbxproj
+++ b/ShhShell.xcodeproj/project.pbxproj
@@ -13,8 +13,12 @@
A92538CD2DEE0744007E0A18 /* ShhShellTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538CB2DEE0744007E0A18 /* ShhShellTests.swift */; };
A92538D12DEE0745007E0A18 /* ShhShellUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538CE2DEE0745007E0A18 /* ShhShellUITests.swift */; };
A92538D22DEE0745007E0A18 /* ShhShellUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A92538CF2DEE0745007E0A18 /* ShhShellUITestsLaunchTests.swift */; };
- A9C897DE2DF1A1C900EF9A5F /* NMSSH.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9C897DC2DF1A1C200EF9A5F /* NMSSH.framework */; };
+ A92D69E82DF1B9ED0031755A /* SSH.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92D69C92DF1B9B00031755A /* SSH.framework */; };
+ A92D69E92DF1B9ED0031755A /* SSH.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A92D69C92DF1B9B00031755A /* SSH.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
A9C897DF2DF1A1C900EF9A5F /* NMSSH.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A9C897DC2DF1A1C200EF9A5F /* NMSSH.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ A9C897EB2DF1A95F00EF9A5F /* NMSSH.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9C897E92DF1A53B00EF9A5F /* NMSSH.framework */; };
+ A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */; };
+ A9C897F12DF1AB5700EF9A5F /* ShellHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C897F02DF1AB5700EF9A5F /* ShellHandler.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -32,6 +36,20 @@
remoteGlobalIDString = A92538992DEE06DC007E0A18;
remoteInfo = ShhShell;
};
+ A92D69C82DF1B9B00031755A /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = A92D69AD2DF1B9AF0031755A /* Blink.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = 07FABB8425C9AEC000E1CC2C;
+ remoteInfo = SSH;
+ };
+ A9C897E82DF1A53B00EF9A5F /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = A9C897D22DF1A18C00EF9A5F /* NMSSH-iOS.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = 186CC9581B69110500F674C4;
+ remoteInfo = NMSSH;
+ };
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -42,6 +60,7 @@
dstSubfolderSpec = 10;
files = (
A9C897DF2DF1A1C900EF9A5F /* NMSSH.framework in Embed Frameworks */,
+ A92D69E92DF1B9ED0031755A /* SSH.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -58,8 +77,11 @@
A92538CB2DEE0744007E0A18 /* ShhShellTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShhShellTests.swift; sourceTree = ""; };
A92538CE2DEE0745007E0A18 /* ShhShellUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShhShellUITests.swift; sourceTree = ""; };
A92538CF2DEE0745007E0A18 /* ShhShellUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShhShellUITestsLaunchTests.swift; sourceTree = ""; };
+ A92D69AD2DF1B9AF0031755A /* Blink.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Blink.xcodeproj; path = /Users/neon443/Downloads/blink/Blink.xcodeproj; sourceTree = ""; };
A9C897D22DF1A18C00EF9A5F /* NMSSH-iOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "NMSSH-iOS.xcodeproj"; path = "Carthage/Checkouts/NMSSH/NMSSH-iOS.xcodeproj"; sourceTree = ""; };
A9C897DC2DF1A1C200EF9A5F /* NMSSH.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = NMSSH.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHHandler.swift; sourceTree = ""; };
+ A9C897F02DF1AB5700EF9A5F /* ShellHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellHandler.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -67,7 +89,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- A9C897DE2DF1A1C900EF9A5F /* NMSSH.framework in Frameworks */,
+ A9C897EB2DF1A95F00EF9A5F /* NMSSH.framework in Frameworks */,
+ A92D69E82DF1B9ED0031755A /* SSH.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -98,6 +121,7 @@
A9C897D22DF1A18C00EF9A5F /* NMSSH-iOS.xcodeproj */,
A9C8976F2DF1980900EF9A5F /* Frameworks */,
A925389B2DEE06DC007E0A18 /* Products */,
+ A92D69AD2DF1B9AF0031755A /* Blink.xcodeproj */,
);
sourceTree = "";
};
@@ -115,6 +139,8 @@
isa = PBXGroup;
children = (
A92538C62DEE0742007E0A18 /* ShhShellApp.swift */,
+ A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */,
+ A9C897F02DF1AB5700EF9A5F /* ShellHandler.swift */,
A92538D32DEE0749007E0A18 /* Views */,
);
path = ShhShell;
@@ -153,6 +179,14 @@
path = Resources;
sourceTree = "";
};
+ A92D69B12DF1B9B00031755A /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ A92D69C92DF1B9B00031755A /* SSH.framework */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
A9C8976F2DF1980900EF9A5F /* Frameworks */ = {
isa = PBXGroup;
children = (
@@ -164,6 +198,7 @@
A9C897E12DF1A53B00EF9A5F /* Products */ = {
isa = PBXGroup;
children = (
+ A9C897E92DF1A53B00EF9A5F /* NMSSH.framework */,
);
name = Products;
sourceTree = "";
@@ -269,6 +304,10 @@
productRefGroup = A925389B2DEE06DC007E0A18 /* Products */;
projectDirPath = "";
projectReferences = (
+ {
+ ProductGroup = A92D69B12DF1B9B00031755A /* Products */;
+ ProjectRef = A92D69AD2DF1B9AF0031755A /* Blink.xcodeproj */;
+ },
{
ProductGroup = A9C897E12DF1A53B00EF9A5F /* Products */;
ProjectRef = A9C897D22DF1A18C00EF9A5F /* NMSSH-iOS.xcodeproj */;
@@ -283,6 +322,23 @@
};
/* End PBXProject section */
+/* Begin PBXReferenceProxy section */
+ A92D69C92DF1B9B00031755A /* SSH.framework */ = {
+ isa = PBXReferenceProxy;
+ fileType = wrapper.framework;
+ path = SSH.framework;
+ remoteRef = A92D69C82DF1B9B00031755A /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+ A9C897E92DF1A53B00EF9A5F /* NMSSH.framework */ = {
+ isa = PBXReferenceProxy;
+ fileType = wrapper.framework;
+ path = NMSSH.framework;
+ remoteRef = A9C897E82DF1A53B00EF9A5F /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+/* End PBXReferenceProxy section */
+
/* Begin PBXResourcesBuildPhase section */
A92538982DEE06DC007E0A18 /* Resources */ = {
isa = PBXResourcesBuildPhase;
@@ -315,6 +371,8 @@
files = (
A92538C82DEE0742007E0A18 /* ContentView.swift in Sources */,
A92538C92DEE0742007E0A18 /* ShhShellApp.swift in Sources */,
+ A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */,
+ A9C897F12DF1AB5700EF9A5F /* ShellHandler.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
new file mode 100644
index 0000000..10489df
--- /dev/null
+++ b/ShhShell.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -0,0 +1,87 @@
+{
+ "originHash" : "3c0aff882bcb0d68be09455d4b0d93dfcf0115ebcb0b9f3c8150da7d6ca8b6c0",
+ "pins" : [
+ {
+ "identity" : "base32kit",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/jenslauterbach/Base32Kit.git",
+ "state" : {
+ "revision" : "34e7e2796cb8d791df6f9a275a858048fcf52700",
+ "version" : "0.2.1"
+ }
+ },
+ {
+ "identity" : "purchases-ios",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/RevenueCat/purchases-ios.git",
+ "state" : {
+ "revision" : "ae6b639cacd045c06ee92ca80b49e34255375ee3",
+ "version" : "4.43.6"
+ }
+ },
+ {
+ "identity" : "runestone",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/simonbs/Runestone",
+ "state" : {
+ "revision" : "1fad339aab99cf2136ce6bf8c32da3265b2e85e5",
+ "version" : "0.5.1"
+ }
+ },
+ {
+ "identity" : "sqlite.swift",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/stephencelis/SQLite.swift",
+ "state" : {
+ "revision" : "a95fc6df17d108bd99210db5e8a9bac90fe984b8",
+ "version" : "0.15.3"
+ }
+ },
+ {
+ "identity" : "swiftcbor",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/unrelentingtech/SwiftCBOR",
+ "state" : {
+ "branch" : "master",
+ "revision" : "ea5ece79b0efde241495bfaa74eccceeffc382bc"
+ }
+ },
+ {
+ "identity" : "swiftui-cached-async-image",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/lorenzofiamingo/swiftui-cached-async-image",
+ "state" : {
+ "branch" : "main",
+ "revision" : "4f111f2b7aab7ec52a60716cedb673df5203743c"
+ }
+ },
+ {
+ "identity" : "tree-sitter",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/tree-sitter/tree-sitter",
+ "state" : {
+ "revision" : "98be227227af10cc7a269cb3ffb23686c0610b17",
+ "version" : "0.20.9"
+ }
+ },
+ {
+ "identity" : "treesitterlanguages",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/simonbs/treesitterlanguages",
+ "state" : {
+ "revision" : "15cf3a9ec3ab95e0d058b7df9f35619123c9e02d",
+ "version" : "0.1.10"
+ }
+ },
+ {
+ "identity" : "zipfoundation",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/weichsel/ZIPFoundation.git",
+ "state" : {
+ "revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0",
+ "version" : "0.9.19"
+ }
+ }
+ ],
+ "version" : 3
+}
diff --git a/ShhShell/SSHHandler.swift b/ShhShell/SSHHandler.swift
new file mode 100644
index 0000000..2e1647e
--- /dev/null
+++ b/ShhShell/SSHHandler.swift
@@ -0,0 +1,55 @@
+//
+// SSHHandler.swift
+// ShhShell
+//
+// Created by neon443 on 05/06/2025.
+//
+
+import Foundation
+import NMSSH
+import LibSSH
+
+class SSHHandler: ObservableObject {
+
+ var session: NMSSHSession
+ var shellHandlerDelegate = ShellHandler()
+
+
+ init(
+ session: NMSSHSession = NMSSHSession(host: "localhost:32222", andUsername: "neon443")
+ ) {
+ ssh_new()
+ self.session = session
+ session.connectToAgent()
+ }
+
+ func connect() {
+ session.authenticate(
+ byPublicKey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIaFx9u3BMq2qW1SJzQik7k8/9p9KV8KZ9JehyKKd2Wu",
+ privateKey: """
+-----BEGIN OPENSSH PRIVATE KEY-----
+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz
+c2gtZWQyNTUxOQAAACCGhcfbtwTKtqltUic0IpO5PP/afSlfCmfSXociindlrgAA
+AIgKUk2MClJNjAAAAAtzc2gtZWQyNTUxOQAAACCGhcfbtwTKtqltUic0IpO5PP/a
+fSlfCmfSXociindlrgAAAEClrzCbl2ZGxAdqa1rS3w3ZEDKXi7Ysf4FKJO375Lhx
+54aFx9u3BMq2qW1SJzQik7k8/9p9KV8KZ9JehyKKd2WuAAAAAAECAwQF
+-----END OPENSSH PRIVATE KEY-----
+""",
+ andPassword: nil
+ )
+ if session.isConnected {
+// session.authenticate(byPassword: "password")
+ do {
+ try session.channel.startShell()
+ } catch {
+ print(error.localizedDescription)
+ }
+ session.channel.delegate = shellHandlerDelegate
+ }
+ }
+
+ func testExec() {
+ guard session.isConnected else { return }
+ session.channel.execute("ls", error: nil)
+ }
+}
diff --git a/ShhShell/ShellHandler.swift b/ShhShell/ShellHandler.swift
new file mode 100644
index 0000000..a9172dc
--- /dev/null
+++ b/ShhShell/ShellHandler.swift
@@ -0,0 +1,26 @@
+//
+// ShellHandler.swift
+// ShhShell
+//
+// Created by neon443 on 05/06/2025.
+//
+
+import Foundation
+import NMSSH
+
+class ShellHandler: NSObject, NMSSHChannelDelegate {
+ func channel(_ channel: NMSSHChannel, didReadData message: String) {
+ print(channel)
+ print(message)
+ }
+
+ func channel(_ channel: NMSSHChannel, didReadError error: String) {
+ print(error)
+ print("error")
+ }
+
+ func channelShellDidClose(_ channel: NMSSHChannel) {
+ print(channel)
+ print("closed channel")
+ }
+}
diff --git a/ShhShell/Views/ContentView.swift b/ShhShell/Views/ContentView.swift
index 371618c..b0efb68 100644
--- a/ShhShell/Views/ContentView.swift
+++ b/ShhShell/Views/ContentView.swift
@@ -6,15 +6,20 @@
//
import SwiftUI
-import NMSSH
struct ContentView: View {
+ var sshHandler = SSHHandler()
+
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
+ Button("go") {
+ sshHandler.connect()
+ sshHandler.testExec()
+ }
}
.padding()
}