博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ssh提示输入密码回显
阅读量:7209 次
发布时间:2019-06-29

本文共 948 字,大约阅读时间需要 3 分钟。

  hot3.png

/*1、启动外部进程*/Process process = new ProcessBuilder("bash").redirectErrorStream(true).start();/*2、执行ssh登录命令*/BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));bw.write("ssh -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -t -t root@192.168.1.11");bw.newLine();bw.flush();/*3、试图获取回显*///Thread.sleep(3000);BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));char[] ch = new char[1024];int len = 0;while ((len = br.read(ch)) > -1) {	System.out.print("回显长度("+len+"):"+new String(ch, 0, len));}
linux:/app # java -classpath . SSHClientroot@192.168.170.64's password:

ssh -o BatchMode=yes root@192.168.1.11

If set to “yes”, passphrase/password querying will be disabled.  This option is useful in scripts and other batch jobs where no user is present to supply the password.  The argument must be “yes” or “no”.  The default is “no”.

转载于:https://my.oschina.net/h2do/blog/606473

你可能感兴趣的文章
iOS Dev (60) 怎样实现 UITextView 中的 placeHolder
查看>>
How to set Selenium Python WebDriver default timeout?
查看>>
mysql 关键词相关度排序方法详细示例分析
查看>>
ListView的CheckBox实现全部选中/不选中
查看>>
PHP5与MySQL数据库操作
查看>>
关于数据库的水平切分和垂直切分的一些概念(转)
查看>>
[Entity Framework]获取部分字段的查询
查看>>
iOS 怎么设置 UITabBarController 的第n个item为第一响应者?
查看>>
MySQL的索引创建、删除
查看>>
李洪强iOS开发Swift篇—02_变量和常量
查看>>
兼容iOS 10 资料整理笔记
查看>>
spring 标注 详解
查看>>
python 爬虫 scrapy1_官网教程
查看>>
Leetcode: Counting Bits
查看>>
解决“HTTP/1.1 405 Method not allowed”问题
查看>>
mac/unix系统:C++实现一个端口扫描器
查看>>
Pocket Gem OA: Path Finder
查看>>
【小白的CFD之旅】22 好网格与坏网格
查看>>
MySQL--指定浮点型数据的精确度TRUNCATE
查看>>
[Mac入门]如何在Mac下显示Finder中的所有文件
查看>>