Who knew you could use React to build command line tools?!
Manage your SSH configs with a CLI interface.
$ rssh --help
Manage your SSH configs with a CLI interface.
Usage:
$ rssh <command> <options>
Commands:
init Initialize the cli working directory.
create host Add hosts to your SSH config.
create tunnel Add local forward tunnels to your SSH config.
list Lists all hosts.
show <host> Show a specific host's information.
connect Connect to a configured tunnel.
disconnect Kill a tunnel connection that was created through the CLI.
Options:
--help, -h Display this message.
--version, -v CLI Version.
Examples:
$ rssh init
$ rssh create host
$ rssh create tunnel
$ rssh connect
$ rssh disconnect
npm install -g rssh
rssh init
Although it's a hackathon, we didn't want to be responsible for nuking your SSH config. All writes are made to the project's workspace. You'll probably get some errors about the directory not existing if you run any other commands.
rssh init
).~/.bashnbastions-react-riot-2019/.ssh/config
.cli
referenced in the output that actually means rssh
.rssh disconnect
to close tunnels!ssh -F ~/.bashnbastions-react-riot-2019/.ssh/config <tunnel-host>
DEBUG=* rssh <command>
)In order to get the most out of this tool, it's important to understand what problem it aims to solve.
It's best practices to disconnect your network from the outside world. But what if you don't have physical access to that network? This is very typical when working with cloud service providers. A bastion server can be configured to act as a single entry point into that network, and can be configured to forward your requests to a computer inside the network.
If you ever had to configure an SSH tunnel, you probably already understand that there's a lot of configurations that need to be set up. and it can be difficult to maintain as you have more configurations added.
Here's a great answer explaining the different types of tunnel configurations: https://unix.stackexchange.com/a/115906
This tool helps to set up this specific configuration.
in the end we end up running:
ssh -N <tunnel-host>
Which is the same as:
ssh -N -L <local-port>:<remote-hostname>:<remote-port> <bastion-hostname>
This section outlines how to redirect traffic from localhost:8080
to localhost:3000
.
You will need to make sure remote logins are enabled for your system:
Note: You haven't set up an SSH key before, please follow this awesome guide from GitHub! https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
๐You will need to also make sure your public key (~/.ssh/id_rsa.pub
in this case) is added to ~/.ssh/authorized_keys
.
If you want to know more about SSH configurations, please see here for more information: https://www.ssh.com/ssh/config/
rssh create host
We tried to keep it as simple as possible, but we will prompt you for the following configs:
local-bastion
localhost
<your-username>
22
yes
~/.ssh/id_rsa
rssh create tunnel
At this point you should be able to select the host that we just created, local-bastion
.
The main benefit of this tool is that you can set tunnels from existing hosts. So you just need to configure a host once, and you can create multiple tunnels from that.
We tried to keep it as simple as possible, but we will prompt you for the following configs:
Once a host is selected we will only prompt you for these configs
- Host: 8080-to-3000
- Local Port: 8080
- Remote Host: localhost
- Port: 3000
rssh connect
Select 8080-to-3000
and you're done!
Any traffic that would normally be served on port 3000
is now available to you on port 8080
.
rssh disconnect
Similar to the previous command, except this will close the tunnel.
Please open an issue: https://github.com/Hackbit/reactriot2019-bashinbastions/issues
Since we're deploying with the npm
registry, installing the app will give you the latest version of the application.
Most of the core functionality was working before the entry cutoff period, so if you want to see the work that was done up until that point please use this branch:
Official Cuttoff:
https://github.com/Hackbit/reactriot2019-bashinbastions/tree/react-riot-cutoff
We really enjoyed hacking on this and want to make sure the that what was published let people at least disconnect tunnels that were created via the CLI.
This is the running list of changes that have been made since the submission cutoff:
Changes since the official submission
https://github.com/Hackbit/reactriot2019-bashinbastions/compare/react-riot-cutoff...master
Vista1nik (Participant)
Awesome. Just Awesome.
Haseeb (Participant)
Great utility.
Jon Borgonia (Participant)
this looks super useful. hope to see more built out after the hackathon!
bobmk2 (Participant)
So good. I'll helped by this tool.