Bhanuchander Udhayakumar
Bhanuchander Udhayakumar

Reputation: 1621

Ssh with JSch to a remote machine that asks twice for username and password

I am just doing ssh me1@ipaddress to a remote machine, where I can't understand what is happening. This command again asks for username and password twice like this:

$ ssh me1@ip

username : me2
password : 

I am using JSch which allows specifying one set of username and password like shown below syntax:

new JSch().getSession(userName, connectionIP, connectionPort)

But in this scenario, we need to provide two usernames as me1 and me2.

How can I achieve this using JSch or any other library in Java?

Upvotes: 1

Views: 429

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202088

Your ssh commands starts a shell session. The prompts for the credentials are just regular I/O prompts, as any other. Nothing credentials-specific. So you should provide the input the way, you would provide any other input – by writing it to the shell input stream.

Upvotes: 2

Related Questions