资源简介
请参考http://blog.csdn.net/clariones/article/details/8455345
是解决用JSCH连接远程,执行命令时,又需要输入密码的问题。 例如用JSCH执行“su - root"是需要输入的密码。

代码片段和文件信息
package pkgname.jsh;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class JSchShellMain {
/**
* ription>
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// Change to your server name
String serverUrl = “xxx.xxx.xxx.xxx“;
String userName = “oracle“;
String password = “oracle“;
JSch jsch = new JSch();
Properties config = new Properties();
config.put(“StrictHostKeyChecking“ “no“);
config.put(“compression.s2c“ “zlibnone“);
config.put(“compression.c2s“ “zlibnone“);
Session session = jsch.getSession(userName serverUrl);
session.setConfig(config);
session.setPort(22);
session.setPassword(password);
session.connect();
ChannelShell channel = (ChannelShell) session.openChannel(“shell“);
MySshIOManager mySshIo = new MySshIOManager();
String filename = “JunitResource/cmd.list“;
FileInputStream fins = new FileInputStream(filename);
mySshIo.loadCommands(fins);
fins.close();
channel.setInputStream(mySshIo.getInputStream());
channel.setOutputStream(mySshIo.getOutputStream());
InputStream is = channel.getExtInputStream();
channel.setPtyType(“MO80x25“);
channel.connect();
while(!channel.isClosed()){
Thread.sleep(1000);
}
channel.disconnect();
session.disconnect();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 652 2012-12-28 16:23 WydLab\.classpath
文件 382 2012-11-28 09:14 WydLab\.project
文件 744 2012-12-31 15:05 WydLab\JunitResource\cmd.list
文件 227436 2012-12-28 15:48 WydLab\lib\jsch-0.1.49.jar
文件 1815 2012-12-31 15:23 WydLab\src\pkgname\jsh\JSchShellMain.java
文件 1086 2012-12-31 13:58 WydLab\src\pkgname\jsh\MyCommand.java
文件 1817 2012-12-31 14:57 WydLab\src\pkgname\jsh\MyInputStream.java
文件 1599 2012-12-31 14:57 WydLab\src\pkgname\jsh\MyOutputStream.java
文件 3387 2012-12-31 15:09 WydLab\src\pkgname\jsh\MySshIOManager.java
文件 602 2012-12-31 14:57 WydLab\test\pkgname\jsh\MySshIOTest.java
相关资源
- HAP_Advanced_PDF_Password_Recovery 5.05
- pdfdo password remover 3.0破解汉化绿色版
- Advanced Office Password Recovery_5.10汉化注册
- pdf打开密码暴力破解(含注册码)
- 身份证后六位。全国弱口令top1000常见
- Accent Office Password Recovery v9.6 x64.zip
- PDF Password Remover v4.0.zip
- OFFICE密码破解AdvancedOfficePasswordRecove
- Node.js参考手册-新版.CHM
- 压缩文件密码破解 Advanced Archive Pass
- Hash Crack_ Password Cracking Manual v2.0
- PDF Password Remover V3.1 正版带注册码
- ZIP/RAR密码破解/密码查看工具+注册码
- 专业级的破解PDF密码工具Advanced PDF
- Excel解密工具—Intelore Excel Password Re
- Advanced RAR Password Recovery (专业版含注
- password.txt
- PDFPasswordRemover 最新版+注册码
- PSiCC2-CN中文_Password_Removed.pdf
- AAPasswordRecovery.zip
- Advanced+Office+Password+RecoveryV4.11绿色汉化
- Office Password Recovery Toolbox v4.0.0.3 完美
- Advanced RAR Password Recovery v1.53.48.12 汉化
- AdvancedRARPasswordRecoveryv1.53.48.12汉化版
- password_silence_4090716.zip
- Cisco交换机路由器 Type 7 密码破解器
- Advanced Office Password Recovery Pro 5.50.477
- Advanced office password recovery pro 5.02 企业
- PDF Password Remover v5.0 with Key 破解PDF
- Office Password Recovery Professional
评论
共有 条评论