jsch

Invalid private key when opening SSH tunnel with JSch

耗尽温柔 提交于 2020-07-15 08:18:23
问题 With JSch I'm calling addIdentity() to add a private key and getSession() to open an SSH tunnel. When running this code locally on my Windows machine the opening of the tunnel is working. However when running that same code with the same private key on our CI the following error occurs: 2016-12-07 01:01:32 ERROR SSHConnector:25 - invalid privatekey: [B@4bb4de6a com.jcraft.jsch.JSchException: invalid privatekey: [B@4bb4de6a at com.jcraft.jsch.KeyPair.load(KeyPair.java:747) at com.jcraft.jsch

Invalid private key when opening SSH tunnel with JSch

断了今生、忘了曾经 提交于 2020-07-15 08:18:22
问题 With JSch I'm calling addIdentity() to add a private key and getSession() to open an SSH tunnel. When running this code locally on my Windows machine the opening of the tunnel is working. However when running that same code with the same private key on our CI the following error occurs: 2016-12-07 01:01:32 ERROR SSHConnector:25 - invalid privatekey: [B@4bb4de6a com.jcraft.jsch.JSchException: invalid privatekey: [B@4bb4de6a at com.jcraft.jsch.KeyPair.load(KeyPair.java:747) at com.jcraft.jsch

How to achieve port forwarding in android

北战南征 提交于 2020-07-11 04:19:09
问题 I have created a web server in android, using NanoHttpd , I would like to forward this . If the server was running on a machine , then I can do it via ssh command like following ssh -p 4000 -R test:80:localhost:1337 ssh.mydomain.net I would like to do the exact same thing in android , I have explored a library called JSch , but in all example it always requires an username and password . But as you can see , in the above command , there is no username or password required . So my question is

How to run SSH command in android programmatically

浪子不回头ぞ 提交于 2020-07-10 03:11:24
问题 I would like to run a simple SSH command like ssh -R 80:localhost:1337 serveo.net , I know there is library jsch to do this , but it will not work without username and password . In my case there is no authentication is required . How can I do this ? Update When I run the command ssh -R 80:localhost:1337 serveo.net -v , I get the following output debug1: Server host key: ssh-rsa SHA256:07jcXlJ4SkBnyTmaVnmTpXuBiRx2+Q2adxbttO9gt0M The authenticity of host 'serveo.net (159.89.214.31)' can't be

How to execute interactive commands and read their sparse output from Java using JSch

萝らか妹 提交于 2020-06-25 05:35:13
问题 Currently I can use the JSch library to execute remote commands in a SSH session like this: JSch jsch = new JSch(); Session session = jsch.getSession(username, host, 22); session.setPassword(password); Properties config = new Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); ChannelExec channel = (ChannelExec) session.openChannel("exec"); BufferedReader in = new BufferedReader(new InputStreamReader(channel.getInputStream())); channel

Executing multiple commands over SSH “exec” channel on firewall device with Java JSch does not work

99封情书 提交于 2020-05-28 07:02:47
问题 I referred the question Multiple bash commands and implemented as below. I am connecting to a device for which first command should be configure then only I will get a prompt to execute all other commands. I don't get output for any of the commands and the control does not return. The following are the commands that work in terminal. ssh uname@ip configure # this command changes prompt and enable following commands move shared pre-rulebase security rules TEST top commit exit exit As asked for

Executing multiple commands over SSH “exec” channel on firewall device with Java JSch does not work

只愿长相守 提交于 2020-05-28 07:01:33
问题 I referred the question Multiple bash commands and implemented as below. I am connecting to a device for which first command should be configure then only I will get a prompt to execute all other commands. I don't get output for any of the commands and the control does not return. The following are the commands that work in terminal. ssh uname@ip configure # this command changes prompt and enable following commands move shared pre-rulebase security rules TEST top commit exit exit As asked for

Connecting to Mongo database through SSH tunnel in Java

眉间皱痕 提交于 2020-05-22 19:46:07
问题 FIXED (edited code to reflect changes I made) I'm trying to connect to a Mongo database through an SSH tunnel using Java. I'm using the Mongo driver 3.0.2 and jcraft (JSch) to create an SSH tunnel. The idea is that I: connect to the machine hosting the MongoDB installation through SSH set up port forwarding from a local port to the remote MongoDB port connect to MongoDB remotely My code looks like this: // forwarding ports private static final String LOCAL_HOST = "localhost"; private static

Connecting to Mongo database through SSH tunnel in Java

天大地大妈咪最大 提交于 2020-05-22 19:45:07
问题 FIXED (edited code to reflect changes I made) I'm trying to connect to a Mongo database through an SSH tunnel using Java. I'm using the Mongo driver 3.0.2 and jcraft (JSch) to create an SSH tunnel. The idea is that I: connect to the machine hosting the MongoDB installation through SSH set up port forwarding from a local port to the remote MongoDB port connect to MongoDB remotely My code looks like this: // forwarding ports private static final String LOCAL_HOST = "localhost"; private static

JSCH addIdentity public key argument doesn't make a difference

▼魔方 西西 提交于 2020-05-13 07:55:10
问题 public class FTP { public static void main(String args[]){ JSch jsch = new JSch(); jsch.setKnownHosts("./known_hosts"); Path privateKeyPath = Paths.get("./id_dsa"); byte[] privateKey = Files.readAllBytes(privateKeyPath); Path publicKeyPath = Paths.get("./id_dsa.pub"); byte[] publicKey = Files.readAllBytes(publicKeyPath); // Either of the lines below work... Why? // jsch.addIdentity("", privateKey, publicKey, null); // or jsch.addIdentity("", privateKey, null, null); Session session = jsch