iOS-NMSSH

作者: iLeooooo | 来源:发表于2020-11-16 13:51 被阅读0次

在Swift项目中使用SSH登录路由器

使用三方库NMSSH连接

pod 'NMSSH'

xxx-Bridging-Header文件中导入头文件

// NMSSH
#import <NMSSH/NMSSH.h>

在项目中使用方法

let session = NMSSHSession.connect(toHost: "10.0.0.254", withUsername: "root")
if session.isConnected {
    print("Successfully created a new session")
}
session.authenticate(byPassword: "password")
if session.isAuthorized {
    print("Successfully authorized")
    let response = session.channel.execute("df -h", error: nil, timeout: 3)
    print("---res--\(response)")
}
session.disconnect()

相关文章

  • iOS-NMSSH

    在Swift项目中使用SSH登录路由器 使用三方库NMSSH连接 在xxx-Bridging-Header文件中导...

网友评论

      本文标题:iOS-NMSSH

      本文链接:https://www.haomeiwen.com/subject/mwoabktx.html