jsch

com.jcraft.jsch.JSchException: UnknownHostKey

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use Jsch to establish an SSH connection in Java. My code produces the following exception: com.jcraft.jsch.JSchException: UnknownHostKey: mywebsite.com. RSA key fingerprint is 22:fb:ee:fe:18:cd:aa:9a:9c:78:89:9f:b4:78:75:b4 I cannot find how to verify the host key in the Jsch documentation. I have included my code below. import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; public class ssh { public static void main(String[] arg) { try { JSch jsch = new JSch(); //create SSH connection String host = "mywebsite.com";

Multiple commands using JSch

匿名 (未验证) 提交于 2019-12-03 01:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: My requirement is as follow: I have to login to Unix box using my credentials and once login, I have to do sudo to different user. Once sudo is successful, I have to invoke shell in nohup. On completion of executions, close channel and session both. I tried the first step which is connect using sudo command, but I don't know how to invoke shell script after the sudo command. In the below code I am able to execute sudo command, but after getting sudo access how can I execute a shell in nohup with user masteruser . So that required

JSCH - Invalid private key

匿名 (未验证) 提交于 2019-12-03 01:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am running JDK 1.7 & Windows 7 using netbeans 7.2 I have generated a SSH private & public key pair (SSH2-2048 bits) using putty-keygen. I do not have any password for private key. I am now trying to connect to one of the host machine using SFTP. But when I pass private key (ppk) to set Identity, code is returning invalid private key error. I used same private key in WinSCP to connect to same host & it is working fine. Kindly help me to resolve the error. Here is my code: JSch jsch = new JSch(); Session session = null; try { jsch

Java SFTP Transfer Library [closed]

匿名 (未验证) 提交于 2019-12-03 01:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking for a dead simple Java Library to use for SFTP file transfers. I don't need any other features beyond that. I've tried Zehon's, but it's incredible naggy, and I think 8 jar files is a bit crazy for so little functionality as I require. And the library have to be free (as in free beer), and preferable Open Source (not a requirement). Thanks. 回答1: Edit : I'm going to keep my previous answer, as JSch is still used in many places, but if you need a better-documented library, you can use sshj . An example in how to use it to do sftp

Jsch or SSHJ or Ganymed SSH-2?

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to connect to server(username,pasw,host)-- easy enter 3-10 commands -- command="dir;date;cd;dir" is there an easier way ?, without writing 20 lines: while(smtng) { a lot of stuff+ mysterious print to scr:D } download a file-- easy write another downloaded file to the same file (add not owerride) -- any ideas how? So to perform these increadible easy tasks, which might seem impossible if you dare to use Jsch(awsome documentation), there is a choise between Jsch,sshj,Ganymed any suggestions? Mystery: 2) multiple commands entering 4)

How to read JSch command output?

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have the following code: JSch jsch = new JSch (); jsch . setKnownHosts ( dotSshDir + "/known_hosts" ); jsch . addIdentity ( dotSshDir + "/id_rsa" ); Session session = jsch . getSession ( userName , hostname , 22 ); session . connect (); ChannelExec channel = ( ChannelExec ) session . openChannel ( "exec" ); channel . setCommand ( command ); channel . setInputStream ( null ); channel . setErrStream ( System . err ); Reader reader = new InputStreamReader ( channel . getInputStream ()); char [] buf = new char [ 1024 ]; int numRead ;

com.jcraft.jsch.JSchException: UnknownHostKey

匿名 (未验证) 提交于 2019-12-03 01:11:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to use Jsch to establish an SSH connection in Java. My code produces the following exception: com . jcraft . jsch . JSchException : UnknownHostKey : mywebsite . com . RSA key fingerprint is 22 : fb : ee : fe : 18 : cd : aa : 9a : 9c : 78 : 89 : 9f : b4 : 78 : 75 : b4 I cannot find how to verify the host key in the Jsch documentation. I have included my code below. import com . jcraft . jsch . JSch ; import com . jcraft . jsch . Session ; public class ssh { public static void main ( String [] arg ) { try { JSch jsch = new

Java JSch changing user on remote machine and execute command

匿名 (未验证) 提交于 2019-12-03 01:07:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to connect to a host, then change the user using "su - john" and then execute a command as john. Is it possible with using only JSch? The problem is that after I create a session and open the channel and execute the aforementioned command it should request password, but nothing happens. This is how I connect to the remote machine: String address = "myremote.computer.com" ; JSch jsch = new JSch (); String user = "tom" ; String host = address ; String password = "l33tpaSSw0rd" ; Session session = jsch . getSession ( user ,

JSch: How to keep the session alive and up

匿名 (未验证) 提交于 2019-12-03 01:07:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm writing Java GUI program for static route management using SSH. My code is as follows: import com.jcraft.jsch.*; import java.io.*; public class Konsep { String status; static String username; static String hostname; String inputcommand; String output; static Session session; JSch jsch = new JSch(); public String status(String stringstatus) { stringstatus = status; return stringstatus; } public String InputCommand(String inputcommandstatus) { inputcommandstatus = inputcommand; return inputcommandstatus; } public void connect(String

JSCH - Invalid private key

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am running JDK 1.7 & Windows 7 using netbeans 7.2 I have generated a SSH private & public key pair (SSH2-2048 bits) using putty-keygen. I do not have any password for private key. I am now trying to connect to one of the host machine using SFTP. But when I pass private key (ppk) to set Identity, code is returning invalid private key error. I used same private key in WinSCP to connect to same host & it is working fine. Kindly help me to resolve the error. Here is my code: JSch jsch = new JSch(); Session session = null; try { jsch