Re: [JSch-users] Can the SSH library prompt us for a password ?
Status: Alpha
Brought to you by:
ymnk
From: Paul M. R. <pm...@pa...> - 2009-11-26 12:45:28
|
On 11/26/2009 06:19 AM, Prasad Shindikar wrote: > Hello JSch Users, > > I want the SSH library to connect (create input / output streams) to the > remote machine and prompt me for a password. > > This is because, in the production environment, there are a lot of > security checks that kick in and hence I need to provide encrypted > password, or something similar to a public key to login successfully to > the machine. > > However, since I cannot know that before hand, if I am able to read > "Password:" from the stream; I will provide a password else I will > provide the encrypted data. I think you would be better off building a two tier connection: first you attempt to connect using a PKI approach. Should that fail (your code should be catching this failure via an exception of some sort such that you know the key didn't do the trick). Knowing this, you would invoke a GUI or command line I/O interaction with the User to provide a password and then try again using a password based approach. It pains me to see JSch APIs that blur business side logic and User interaction. This is just plain bad design, especially in the face of a broad library that has no need for such blurring. > Hope I am being clear here. We'll know shortly. :-) Hope my answer helps. -pmr |