Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6648639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:40:45+00:00 2026-05-26T00:40:45+00:00

I want to ssh into a server from behind another ssh server. The gateway

  • 0

I want to ssh into a server from behind another ssh server. The gateway server requires a username/password and I can do this. I am using a tunnel to get into the next server, but this one requires only an ssh key. I’ve generated the key through PuTTY, so it exists for my username but I’m not sure how to retrieve it for my Java program. Is it a configuration? i.e. setConfig(“userauth.publickey”, “com.jcraft.jsch.UserAuthPublicKey”) then how do I use this or something else? Documentation seems to be sparse and I appreciate any help. Anything I’ve tried gives me an error :”Auth fail” when I connect this session

Thanks!

The tunnel method I use is: http://sourceforge.net/apps/mediawiki/jsch/index.php?title=ProxySSH so thanks to the guy who wrote it!

For context, I’d like to read/write to a server at my school from my Android phone.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:40:45+00:00Added an answer on May 26, 2026 at 12:40 am

    To enable public-key authentication, you have to use one of the JSch.addIdentity methods.

    These take the public and private key in the OpenSSH key format – so make sure you export it from PuTTY in this format. (JSch doesn’t understand PuTTY’s native format, though you could write an adapter implementing the Identity interface, parsing it yourself).

    The identities added to JSch are global, not per-session. This is normally not a problem, as JSch will try all authentication methods which are supported both by itself and the server in order, and public-key authentication is normally before password authentication.

    All authentication methods need a user name (usually the name of the account to be logged into).

    With public-key authentication, the public key must be somehow previously available to the server. For OpenSSH’s sshd, the public key should be listed in ~/.ssh/authorized_keys. (If you have only one public key, simply copy it to this file, if you have multiple ones (each of which will be allowed), each should be on one line.)

    So it should work out-of-the box after setting the identity.

    If you want to make sure the first session uses password authentication and the second (tunneled) one uses public-key, you can use the per-session configuration, overriding the global one:

    tunnelSession.setConfig("PreferredAuthentications", "password");
    
    innerSession.setConfig("PreferredAuthentications", "publickey");
    

    (These are comma-separated lists, here of one element each.)

    About the ProxySSH example, that is by me (with some help by JSch’s author, Atsuhiko Yamanaka). I should add this information to the Wiki page, maybe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can Maven copy local file to a remote server using SSH? I want to
I want to execute some remote command on my server using net-ssh library. I
I want to ssh into my domain's cpanel hosted on a linux server ?
I want to execute source mysite/bin/activate Whever I ssh into that server (and login)
I want to keep SSH debug info separate (and logged) from other input. However,
i want to run some command on several machine using ssh. I know it
I have sixteen servers using Log4J logs, accessible by ssh. I want to see
I want to allow some trusted users to scp files into my server (to
If I have SSH access to a shared server (running centOS) and I want
I want to create an SSH Tunnel in Java. I noticed quite a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.