Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

where to place the Public key

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using com.sshtools.j2ssh API for SFTP connections. I can connect using user name & password. But i want to connect thru public & private key.

what is the folder structure to place the public key in SFTP server?

And also How to check the configuration on SFTP server regarding public key?
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

A bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Initials aren't enough. You can change your display name here. Thanks!
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I'm gonna say is linux specific possibly, but the concepts are pretty much the same regardless

You've created a public private key pair using ssh-keygen so that you have a id_rsa, and id_rsa.pub (Use your preferred too here, on windows I always use cygwin ssh-user-config script and then import into other tools as required)

sftp id_rsa.pub onto your target machine.

ssh onto your target machine (which is of course Unix style)

  • mkdir ~/.ssh
  • cd ~/.ssh
  • cat ~/id_rsa.pub >> authorized_keys2
  • cd ..
  • chmod -R 700 .ssh


  • The last step is possibly optional depending on your umask, but I do tend to find that ssh servers get a bit uppity if the .ssh directory and contents are group/world readable.

    Logout and Login.

    authorized_keys2 is for ssh2 authentication, authorized_keys for ssh1 authentication. ssh2 is more secure than ssh1, and most servers should support it.

    Lewin
     
    The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!