sshj

SSHJ Example of Public Key Auth from File

ぃ、小莉子 提交于 2019-11-30 20:46:57
Can someone give me an example of using SSHJ for Public Key Authentication? I realise this question is essentially identical to ssh example of private/public key authentication , however the answer by the author https://stackoverflow.com/users/126346/shikhar refers to a google user group that no longer exists, and I am having trouble getting it to work. Thanks! Phil Hiery Nomus We built the overthere framework on top of SSHJ. Which can connect also connect using key files. The following piece of code should work, but make sure you add the bouncycastle library to your classpath. SSHClient

SSH port fowarding with SSHj

江枫思渺然 提交于 2019-11-30 19:04:55
问题 I am trying to create a tunnel to use a service behind a firewall, that supports SSH. I wanted a complete solution in java, but I cannot seem to get it to work. I found this github snip and based on that I created the following code to keep a background thread giving me the tunnel: // property on surrounding class // static final SSHClient sshclient = new SSHClient(); Thread thread = new Thread(new Runnable() { @Override public void run() { try { String host = "10.0.3.96"; sshclient

execute sequense of commands in sshj

混江龙づ霸主 提交于 2019-11-30 07:27:28
问题 I need to execute some sequence of commands at the remote server via ssh, using sshj library. I do Session session = ssh.startSession(); Session.Command cmd = session.exec("ls -l"); System.out.println(IOUtils.readFully(cmd.getInputStream()).toString()); cmd.join(10, TimeUnit.SECONDS); Session.Command cmd2 = session.exec("ls -a"); System.out.println(IOUtils.readFully(cmd2.getInputStream()).toString()); and it throws me net.schmizz.sshj.common.SSHRuntimeException: This session channel is all

SSHJ Example of Public Key Auth from File

橙三吉。 提交于 2019-11-30 04:20:06
问题 Can someone give me an example of using SSHJ for Public Key Authentication? I realise this question is essentially identical to ssh example of private/public key authentication, however the answer by the author https://stackoverflow.com/users/126346/shikhar refers to a google user group that no longer exists, and I am having trouble getting it to work. Thanks! Phil 回答1: We built the overthere framework on top of SSHJ. Which can connect also connect using key files. The following piece of code

Jsch or SSHJ or Ganymed SSH-2?

限于喜欢 提交于 2019-11-29 09:58:19
问题 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

execute sequense of commands in sshj

烂漫一生 提交于 2019-11-29 03:57:15
I need to execute some sequence of commands at the remote server via ssh, using sshj library. I do Session session = ssh.startSession(); Session.Command cmd = session.exec("ls -l"); System.out.println(IOUtils.readFully(cmd.getInputStream()).toString()); cmd.join(10, TimeUnit.SECONDS); Session.Command cmd2 = session.exec("ls -a"); System.out.println(IOUtils.readFully(cmd2.getInputStream()).toString()); and it throws me net.schmizz.sshj.common.SSHRuntimeException: This session channel is all used up But I can't recreate session for every single command, because this example it will show home

SSHJ - Keypair login to EC2 instance

本秂侑毒 提交于 2019-11-27 14:30:46
I have a pem file that looks like the one in SSHJ tests (though I don't see it being referenced): https://github.com/shikhar/sshj/blob/master/src/test/resources/hostkey.pem . Simply trying to auth in via the pem file to an EC2 instance (read as string), but having trouble. Anyone done this? SSHClient ssh = new SSHClient(); ssh.connect("ec2-XXXXXXX.compute-1.amazonaws.com"); ssh.authPublickey("ubuntu", getPemAsString("/Users/me/ec2.pem")); final Session session = ssh.startSession(); session.exec("echo -e \"test\" >> /home/ubuntu/testfile"); Error is below: INFO [main] (TransportImpl.java:152) -

SSHJ - Keypair login to EC2 instance

こ雲淡風輕ζ 提交于 2019-11-26 16:46:41
问题 I have a pem file that looks like the one in SSHJ tests (though I don't see it being referenced): https://github.com/shikhar/sshj/blob/master/src/test/resources/hostkey.pem . Simply trying to auth in via the pem file to an EC2 instance (read as string), but having trouble. Anyone done this? SSHClient ssh = new SSHClient(); ssh.connect("ec2-XXXXXXX.compute-1.amazonaws.com"); ssh.authPublickey("ubuntu", getPemAsString("/Users/me/ec2.pem")); final Session session = ssh.startSession(); session