# rssh

> Manage your SSH configs with a CLI interface.

Latest version **1.0.1** (published 2019-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install rssh
pnpm add rssh
yarn add rssh
bun add rssh
```

Provides the command `rssh`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-09-30 |
| First published | 2019-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 10 |
| Unpacked size | 573.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | epilande |

## Links

- npm: https://www.npmjs.com/package/rssh
- Repository: https://github.com/Hackbit/reactriot2019-bashinbastions
- Issues: https://github.com/Hackbit/reactriot2019-bashinbastions/issues
- npm.io page: https://npm.io/package/rssh

## Dependencies (10)

- [mz](https://npm.io/package/mz.md) 2.7.0
- [ink](https://npm.io/package/ink.md) ^2.4.0
- [meow](https://npm.io/package/meow.md) ^5.0.0
- [debug](https://npm.io/package/debug.md) 4.1.1
- [react](https://npm.io/package/react.md) ^16.10.0
- [ps-node](https://npm.io/package/ps-node.md) 0.1.6
- [untildify](https://npm.io/package/untildify.md) 4.0.0
- [ssh-config](https://npm.io/package/ssh-config.md) 2.0.0-beta.1
- [ink-text-input](https://npm.io/package/ink-text-input.md) ^3.2.1
- [ink-select-input](https://npm.io/package/ink-select-input.md) ^3.1.2

## Recent versions

- 1.0.1 (latest) — 2019-09-30
- 1.0.0 — 2019-09-30

## README

<div align="center">
  <h1>reactriot2019-bashinbastions 🥊</h1>
</div>

<p align="center">
  <strong>Manage your SSH configs with a CLI interface.</strong>
</p>

## Installation

```bash
$ npm install -g rssh
# OR
$ npx rssh
```

### ⚠️ Initialize the tools workspace

```bash
$ 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.

## Tips

- Since it _is_ a hackathon we didn't have time to implement editing the config file through the CLI.
- If you make a mistake, you can blow your changes away by re-initializing the project (`rssh init`).
- If you don't want to remove everything you can edit the SSH config directly which is located at `~/.bashnbastions-react-riot-2019/.ssh/config`.
- If you see `cli` referenced in the output that _actually_ means `rssh`.
- 🧹 This tunnel **will** run in the background until you disconnect them! Use `rssh disconnect` to close tunnels!
- If you are setting up a tunnel you've never configured before you may need to accept the fingerprint outside of the application:
  - `ssh -F ~/.bashnbastions-react-riot-2019/.ssh/config <tunnel-host>`
- If you want to see all the debugger logs you can enable it with an environment flag (`DEBUG=* rssh <command>`)

## Future improvements

- Allow you to edit/remove hosts and tunnels
- Support all SSH configs
- Better process management
- Show tunnel status
- Better configuration options
- Better system support

## Overview

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](https://en.wikipedia.org/wiki/Bastion_host) 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.

![Local Forward Tunnel](https://i.stack.imgur.com/a28N8.png)

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

## Exercise: Redirecting from one local port to another local port

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:

- [Mac](https://www.google.com/search?q=enable+remote+ssh+login+mac)
- [Linux](https://www.google.com/search?q=enable+remote+ssh+login+linux)
- [Windows](https://www.google.com/search?q=enable+remote+ssh+login+windows)
  - This CLI relies entirely on the `ssh` command, so your mileage may vary!

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

## Add a host

```bash
rssh create host
```

We tried to keep it as simple as possible, but we will prompt you for the following configs:

- Host: `local-bastion`
- HostName: `localhost`
- User `<your-username>`
- Port `22`
- ForwardAgent `yes`
- IdentityFile `~/.ssh/id_rsa`

## Add a tunnel

```bash
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`

## Start the tunnel

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

## Closing the tunnel

```bash
rssh disconnect
```

Similar to the previous command, except this will close the tunnel.

## Development

### Clone this repo

```bash
$ git clone https://github.com/Hackbit/reactriot2019-bashinbastions.git
$ cd reactriot2019-bashinbastions
```

### Install dependencies

```bash
$ yarn install
```

### Launch dev environment

Watch files in [`src`](./src) directory for changes and transpile it to `dist`.

```bash
$ yarn dev
```

### Run CLI

Run [`cli.js`](./cli.js) which will use files from `dist`.

```bash
$ yarn start
```

### Build for production

```bash
$ yarn build
```

### Publish package

Bump the [`package.json`](./package.json#L3) version then run the following:

```bash
$ yarn publish
```

---
_Source: https://npm.io/package/rssh · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
