简体   繁体   中英

SFTP public/private key authentication - can it work without the key location?

I use the Jscape library to implement a SFTP client. The pieces of information I need is usually the following: 1. Host 2. Port 3. User ID 4. Private key's location 5. Passphrase (optional in some cases)

My question is : is there any way to use private key without specifying the private key's location? For example, the key could be dropped to a certain location and Jscape or some other SFTP API out there would somehow "see" it?

Jscape doesn't seem to support that. I've tried putting a non-passphrase-protected key next to the sftp.jar file (the Jscape library) and that didn't work.

I know specifying the key's location is fairly straightforward and it certainly is one of the use cases I have. But I do have reasons behind asking this silly-sounding question. I appreciate any insight!

OpenSSH's command line client uses $HOME/.ssh/id_rsa as the default location for the private key, and a few other applications seem to follow this (eg git). So if you're implementing code on top of JScape, you could also use that convention.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM