I am creating a command-line tool that dynamically finds a server from our cluster, then based on the cluster retrieves the appropriate private key held in an Amazon s3 bucket and copies it to a tempfile locally to connect to the server.
How would I SSH into an IP address and then allow the user to interact with the SSH session?
This example would open a ssh session to a machine in the cluster named "platform":
company_name ssh:platform
I've done this before in Ruby like so:
exec("ssh -i #{private_key_file.path} -R 52698:localhost:52698 core@#{platform_ip}")
You probably want to take a look at the ssh2-rs crate; the docs have a good example of what you're trying to accomplish.
The gist of it is that you get a channel_session object, which has methods to read the outputs from the SSH console (copied from the docs here):