scala-ssh icon indicating copy to clipboard operation
scala-ssh copied to clipboard

how to chain logins?

Open ehudkaldor opened this issue 13 years ago • 3 comments

i need to log in to one ssh, and from it i need to log to another. how do i pass the username and password for the seond login? when i pass "; " after the second login command, it just grinds and time out eventually with nothing.

ehudkaldor avatar Dec 20 '12 06:12 ehudkaldor

This is something I haven't tried yet and isn't officially supported. Do you have a full example that I could play with?

sirthias avatar Dec 20 '12 10:12 sirthias

i need to login to a local account that does not allow ssh. so, i need to ssh into the machine (initial connection) and from it login to the local account.

a use case you can use for testing:

  • create 2 account on a machine
  • ssh to one account
  • after login, ssh to secondAccount@localhost

looking at the source code, it seems like a command is run as a single transaction, and then closes the connection. you can still run several commands seperated by semi-colon (cd /home/ehud/dir/; ls -la) but that does not work for login, as the console expects an interactive response. it occuered to me one way that might work is to create a MultiCommand class which extends (or expands) Command, or which will hold a set of commands, and change SshClient.exec, to run through all the commands sequentially (in val channel = session.exec(command.command)). don't know if that is the right way, but i thought i might fork and try it...

ehudkaldor avatar Dec 20 '12 16:12 ehudkaldor

Is this supported now?

emaillenin avatar Aug 03 '18 06:08 emaillenin