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 6814087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:38:48+00:00 2026-05-26T20:38:48+00:00

I’m looking at setting up public key client and server authentication for SFTP using

  • 0

I’m looking at setting up public key client and server authentication for SFTP using the JSch library (or actually the sharpSSH C# port of it). Unfortunately I cannot find any documentation for the file formats used by the key loading functions:

jsch.addIdentity(filename, passphrase);
jsch.setKnownHosts(filename);

What file format is used by the private key and known hosts files?

  • 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-26T20:38:48+00:00Added an answer on May 26, 2026 at 8:38 pm

    JSch uses the OpenSSH key file format (both for public and private keys). I didn’t find a specification of this format, but you can use OpenSSH’s ssh-keygen tool to convert the keys from/to other formats (and Google will show other tools of converting from/to even more formats).

    Update: After asking on the OpenSSH mailing list and reading some RFC’s, it looks like OpenSSH’s public key file contains (for version 2 keys) the public key as specified in RFC 4253 (section 6.6), just with a base64-wrapping around it (and the key type as prefix, and a comment field as postfix). I still didn’t yet find a specification for the private key file.

    Unfortunately, the official documentation for JSch is almost nonexistent, but I did write some Javadocs for it. (Though it seems not to mention the key file format … I’ll have to fix this.)
    There is also the Manual in the JSch Wiki, containing a page about public key authentication (which also doesn’t mention the key format yet :-/).

    The known hosts file is also in the same format as the corresponding file of the OpenSSH client. It’s format is explained in OpenSSH’s sshd manual page, section SSH KNOWN HOSTS FILE FORMAT:

    Each line in these files contains the following fields: markers
    (optional), hostnames, bits, exponent, modulus, comment. The fields are
    separated by spaces.

    This is actually only correct for SSH 1 RSA keys. For SSH 2 keys, you have a type identifier (ecdsa-sha2-nistp256,ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-dss or ssh-rsa) and then the key in base-64 encoded form. (See a bit up in the same manual page, for the authorized keys file). (I think JSch only supports the DSA and RSA key formats, no ECDSA.)

    Note that the lines in these files are typically hundreds of characters
    long, and you definitely don’t want to type in the host keys by hand.
    Rather, generate them by a script, ssh-keyscan(1) or by taking
    /etc/ssh/ssh_host_key.pub and adding the host names at the front.
    ssh-keygen(1) also offers some basic automated editing for
    ~/.ssh/known_hosts including removing hosts matching a host name and
    converting all host names to their hashed representations.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.