如何修复建立连接NMSSH的失败

时间:2019-11-14 18:32:58

标签: swift nmssh

如何在Swift中使用NMSSH? 当我执行以下代码时,我会在调试控制台中收到以下消息:

2019-11-14 19:15:53.830479+0100 unLock[49480:480479] NMSSH: Start 192.168.178.97 resolution
2019-11-14 19:15:53.832950+0100 unLock[49480:480481] NMSSH: Socket connection to 192.168.178.97 on port 44 failed with reason -1, trying next address...
2019-11-14 19:15:53.833005+0100 unLock[49480:480481] NMSSH: Failure establishing socket connection
2019-11-14 19:15:53.833047+0100 unLock[49480:480481] NMSSH: Disconnected

代码:

let session = NMSSHSession(host: "192.168.178.97:44", andUsername: "root")
        session.connect()
        if session.isConnected == true{
            session.authenticate(byPassword: "alpine")
            //if session.isAuthorized == true {
                session.channel.execute("killall SpringBoard", error: nil)
                print("killed Springboard")
            //}
        }

我所做的是允许对App Transport Security进行任意加载,因为我认为问题可能是ssh服务器不是HTTPS,但它没有帮助。我尝试通过SSH连接到iPhone的事实并不是Haswell的原因,就像我在Raspberry Pi上尝试的那样,结果相同。同样不要介意端口44,因为它是checkra1n的正确端口。

1 个答案:

答案 0 :(得分:0)

您可以在此处看到类似的类型问题。

How to use NMSSH in swift

还请阅读NMSSH的自述文件,并使用podfile设置此框架。

pod 'NMSSH'

在此处阅读文档

https://github.com/NMSSH/NMSSH