1

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?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Bhanuchander Udhayakumar
  • 1,581
  • 1
  • 12
  • 30

1 Answers1

2

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Thanks for pointing out the obvious deficiency within my question. Just wondering: s there any specific purpose or reasoning why one have or want to use "two" login names like this? – GhostCat Jun 26 '19 at 10:35
  • Thanks for your response. I will try to solve this with `Shell` Channel Type which is very much fit to your answer. – Bhanuchander Udhayakumar Jun 26 '19 at 10:44
  • As I 've changed to my implementation channel type from `exec` to `shell`. It works fine. Thanks and Happy learning...! :) – Bhanuchander Udhayakumar Jun 26 '19 at 11:28
  • 1
    @GhostCat No idea. It's actually possible that the `me1` it not really needed. Maybe the only real login is the `me2`. Some legacy devices that switched from Telnet to SSH do that - They do not use SSH authentication mechanism, but keep the old Telnet-like I/O prompts. – Martin Prikryl Jun 26 '19 at 11:40