内容简介:QuickSSH 1.0.2版本发布,新增isClosed方法,用于检测当前会话是否关闭。此方法适用于连接池场景,需要将SSHClient作为资源存储,需要检测SSHClient是否可用。同时新增Channel类可获取所属的SSHClient方法. 更新功...
QuickSSH 1.0.2版本发布,新增isClosed方法,用于检测当前会话是否关闭。此方法适用于连接池场景,需要将SSHClient作为资源存储,需要检测SSHClient是否可用。同时新增Channel类可获取所属的SSHClient方法.
更新功能使用实例
SSHClient sshClient =QuickSSH.newInstance()
.host(account.host())
.port(account.port())
.username(account.username())
.password(account.password())
.build();
//判断连接是否关闭
sshClient.isClosed();
SFTPChannel sftpChannel = sshClient.sftpChannel();
//获得该频道所属的SSHClient
SSHClient sshClient1 = sftpChannel.getSSHClient();
QuickSSH
纯 Java 实现SSH协议
快速入门
- 导入QuickSSH
<dependency>
<groupId>cn.schoolwow</groupId>
<artifactId>QuickSSH</artifactId>
<version>{最新版本}</version>
</dependency>
<dependency>
<groupId>cn.schoolwow</groupId>
<artifactId>QuickSSH</artifactId>
<version>{最新版本}</version>
</dependency>
- 构建SSHClient
//密码方式登录
SSHClient client = QuickSSH.newInstance()
.host("127.0.0.1")
.port(22)
.username("root")
.password("123456")
.build();
//公钥文件方式登录
SSHClient client = QuickSSH.newInstance()
.host("127.0.0.1")
.port(22)
.username("root")
//目前仅支持rsa类型
.publickey("/path/to/id_rsa", "passphrase")
.build();
//执行exec命令
String resut = sshClient.exec("pwd");
//获取sftp命令
SFTPChannel sftpChannel = sshClient.sftp();
sftpChannel.xxxxxx();
开源协议
本软件使用LGPL开源协议!
衷心希望我们国家的开源事业蓬勃发展,也希望大家能重视底层开发。再好的空中楼阁也终究会坍塌,一步一个脚印才能走的更稳,有些捷径是走不得的。共勉。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Release It!
Michael T. Nygard / Pragmatic Bookshelf / 2007-03-30 / USD 34.95
“Feature complete” is not the same as “production ready.” Whether it’s in Java, .NET, or Ruby on Rails, getting your application ready to ship is only half the battle. Did you design your system to......一起来看看 《Release It!》 这本书的介绍吧!