Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to chain logins? #7

Open
ehudkaldor opened this issue Dec 20, 2012 · 3 comments
Open

how to chain logins? #7

ehudkaldor opened this issue Dec 20, 2012 · 3 comments

Comments

@ehudkaldor
Copy link

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.

@sirthias
Copy link
Owner

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

@ehudkaldor
Copy link
Author

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...

@emaillenin
Copy link

Is this supported now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants