# GOTO - A simple SSH manager #

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/grafviktor/goto/master/LICENSE)
[![Codecov](https://codecov.io/gh/grafviktor/goto/branch/develop/graph/badge.svg?token=tTyTsuCvNb&)](https://codecov.io/gh/grafviktor/goto)
[![Go Report Card](https://goreportcard.com/badge/github.com/grafviktor/goto)](https://goreportcard.com/report/github.com/grafviktor/goto)

This is a tool for managing and organizing your SSH servers. Unlike PuTTY it doesn't include any connection logic, but integrates with `ssh` utility which should be installed on your system. It's perfect for dev teams allowing SSH configurations to be centrally stored on an internal server and shared across developers or entire tech departments.

Supported platforms: macOS, Linux, Windows.

## 1. Installation ##

### 1.1 Manual ###

* Download the latest version from the [Releases](https://github.com/grafviktor/goto/releases) section;
* Choose a binary file which matches your platform;
* Place the binary into your user's binary path;
* Optionally: rename `gg-${YOUR_PLATFORM_TYPE}` to `gg`.
* If you're on Linux or macOS, ensure that the binary has execution permissions:
  ```bash
  chmod +x gg
  ```

### 1.2 Using package manager ###

#### Debian or RedHat ####

RPM and DEB packages are available in the [releases](https://github.com/grafviktor/goto/releases/latest) section (these packages are not provided for pre-release builds).

#### Arch Linux (AUR) ####

_Maintained externally by the open-source community._

Install [goto-ssh-bin](https://aur.archlinux.org/packages/goto-ssh-bin) package. Also see the [build](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=goto-ssh-bin) file for additional details.

```bash
# Install goto
yay -S goto-ssh-bin
```

#### macOS (Homebrew) ####

You can install `goto` via Homebrew using a community tap:

```bash
brew tap grafviktor/goto
brew install --cask goto-ssh-manager
```

This installs the `gg` binary onto your system. Run it with:
```bash
gg
```

## 2. Functional demo ##

### 2.1. This is your interface to ssh configuration ###

This video demonstrates how to set path to a remote SSH configuration, which is shared among team members.

![Shows how to set path to a remote ssh config file](demo/ssh_config_show_hosts.gif)

_Note: SSH Include directive is also supported. This allows you to create an access hierarchy - for example, a root configuration will be used by UNIX team, with leaf configurations distributed across specific departments. Please read more in [this document](docs/SSH_CONFIG.md)._

### 2.2. Organize your hostnames into logical groups ###

Find more information about hosts grouping [here](docs/GROUPS.md). The video represents hosts grouped into categories such as Dev, Beta, and Prod.

![Shows how to switch between hosts groups](demo/switch_between_groups.gif)

### 2.3. Edit your entries and connect to remote boxes ###

Adjust hostname before connecting to it.

![Shows how to open ssh session using goto](demo/edit_and_connect.gif)

_Note: you can only edit hosts loaded from yaml storage. Please see section 4._

Find more demos and uses cases [here](demo/README.md).

## 3. Configuration ##

* Please see more information about hosts grouping in [this document](docs/GROUPS.md) and ssh_config usage in [that document](docs/SSH_CONFIG.md).
* Also refer [F.A.Q.](docs/FAQ.md) page which provides additional configuration details and usage examples.

### 3.1. Command line options ###

* `-f` - specify the application home folder;
  ```bash
  gg -f /tmp/goto
  ```
* `-l` - log verbosity level. Only `info`(default) or `debug` values are currently supported;
  ```bash
  gg -l debug
  ```
* `-s` - define an alternative SSH configuration file path for current session;
  ```bash
  gg -s /mnt/nfs_share/ssh/config
  ```
* `--set-ssh-config-path` - set SSH configuration file path or url;
  ```bash
  gg --set-ssh-config-path https://company-repo/devops-team/ssh_config
  ```
* `-d` - disable feature, only supported value is ssh_config;
  ```bash
  gg -d "ssh_config"
  ```
* `-e` - enable feature, only supported value is ssh_config;
  ```bash
  gg -e "ssh_config"
  ```
* `--set-theme` - set application color theme;
  ```bash
  gg --set-theme nord
  ```
* `-h` - display help;
* `-v` - display version and configuration details.

### 3.2. Environment variables ###

* `GG_HOME` - specify the application home folder;
* `GG_LOG_LEVEL` - set log verbosity level. Only `info`(default) or `debug` values are currently supported.
* `GG_SSH_CONFIG_FILE_PATH` - define an alternative per-user SSH configuration file path.

## 4. File storage structure ##

2 file storages are supported:

* ssh_config - readonly storage type. Goto loads all hosts from your `~/.ssh/config` file. See `man ssh_config`, if you want to find out more about OpenSSH client configuration file. The application also supports remote ssh_config files. Please read [SSH_CONFIG.md](docs/SSH_CONFIG.md) document for more details about ssh_config usage with GOTO.
* yaml file - writable storage type, but supports less options than ssh_config. Please section 4.1 if you want to find out more about yaml file structure and its location.

### 4.1 Yaml storage location and structure ###

You can only store your hosts in a yaml file, which is called `hosts.yaml`. The file is located in your user config folder which exact path depends on a running platform:

* on Linux, it's in `$XDG_CONFIG_HOME/goto` or `$HOME/.config/goto`;
* on Mac, it's in `$HOME/Library/Application Support/goto`;
* on Windows, it's in `%AppData%\goto`.

Usually you don't need to edit this file manually, but sometimes it's much more convenient to edit it with help of your favorite text editor, than using `goto` utility. The file structure is very simple and self-explanatory:

```yaml
- host:
    title: kernel.org
    description: Server 1
    address: 127.0.0.1
- host:
    title: microsoft.com
    description: Server 2
    address: 127.0.0.1
    network_port: 22
    username: satya
    identity_file_path: /home/user/.ssh/id_rsa_microsoft
```

## 5. Known issues and limitations ##

* Application may not start on Windows platform if your terminal is set to use legacy console. Either disable legacy console mode or run terminal session manually and then start the application from the inside. Google "how to disable legacy console on windows" for more details.
* On Windows, copying your SSH public key to a remote host using the `t` shortcut may fail if the remote host does not already have a `~/.ssh` directory. In that case, log in to the remote host, create the directory manually, and set the correct permissions (`chmod 700 ~/.ssh`). Once the directory is in place, retry the key-copy operation.
* If your `ssh_config` uses the `Include` directive with a double asterisk, for example:
  ```
  Include .../conf.d/**/*.conf
  ```
  the application will not be able to locate those files. The current workaround is to specify each folder separately, similar to this:
  ```
  Include .../conf.d/folder1/*.conf
  Include .../conf.d/folder2/*.conf
  ```

## 6. [F.A.Q.](docs/FAQ.md) ##

## 7. [Contributing guidelines](CONTRIBUTING.md) ##

## 8. [Changelog](CHANGELOG.md) ##

## 9. [License](LICENSE) ##

## 🙏 Thanks ##

* To people who find time to contribute whether it is a bug report, a feature or a pull request.
* To [Charmbracelet project](https://charm.sh/) for the glamorous [Bubbletea](https://github.com/charmbracelet/bubbletea) library.
* To [JetBrains Team](https://www.jetbrains.com/) for their [support for Open-Source community](https://www.jetbrains.com/community/opensource/) and for the amazing products they make. That is a great boost indeed. I'm proudly placing their logo here as a humble "Thank You" gesture.

<div align="center">
  <a href="https://www.jetbrains.com/">
    <img
      height="40px"
      src="https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg"
      alt="JetBrains logo."
    >
  </a>
</div>
