ios - NMSSH 不与 SWIFT 连接

标签 ios swift ssh nmssh

我只是第一次尝试使用 NMSSH,但它根本无法连接

import UIKit
import NMSSH

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        let session = NMSSHSession(host: "11.111.11.11", andUsername: "vnc")
        if session.connected == true{
            session.authenticateByPassword("1234")
            if session.authorized == true {
                print("works")
            }
        }

    }


}

最佳答案

确实忘记了 session.connect() 来启动连接

let session = NMSSHSession(host: "11.111.11.11", andUsername: "inc")
        session.connect()
        if session.connected == true{
            session.authenticateByPassword("1234")
            if session.authorized == true {
                print("works")
            }
        }

关于ios - NMSSH 不与 SWIFT 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35271828/

相关文章:

ios - 更新 uitableview 标题上的文本

ios - Objective-C - 蛮力算法

ios - 某些网站未在 Swift Xcode 9.2 中加载

Swift 脚本直接在 Xcode Run Script 阶段运行,但由于 NSTask/Process 而不能通过外部文件运行

linux - 通过 ssh 使用 watch

c++ - route-me 与 libosmscout(适用于 iOS 的离线 vector map )

ios - 在同一文件中的 View Controller 之间以 Swift 传递数据

linux - 为 openssh 使用 pam_exec 的帐户的外部脚本

postgresql - AWS RDS 主机访问

iphone - 向 UIToolbar 添加两个 UITextField