Skip to content

Commit

Permalink
Add SSH config parsing and mosh connections
Browse files Browse the repository at this point in the history
- Also parse ~/.ssh/config and /etc/ssh/ssh_config
- Add mosh connections
- Prioritise sources
- Improve handling of user-entered usernames and ports
  • Loading branch information
deanishe committed Oct 31, 2016
1 parent b2d9be6 commit ba3fdc7
Show file tree
Hide file tree
Showing 9 changed files with 746 additions and 220 deletions.
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Secure SHell for Alfred
=======================

Open SSH connections from [Alfred 3][alfredapp] (only) with autosuggestions based on `~/.ssh/known_hosts`, `/etc/hosts` and your history.
Open SSH connections from [Alfred 3][alfredapp] with autosuggestions based on `~/.ssh/known_hosts`, `/etc/hosts` and your history.

!["Secure SHell Demo"][demo]
<!-- !["Secure SHell Demo"](./demo.gif) -->


Features
Expand All @@ -13,11 +12,10 @@ Features
- Auto-suggest hostnames from `/etc/hosts` and `~/.ssh/known_hosts` (sources can be individually disabled).
- Remembers usernames, so you don't have to type them in every time. (You can also remove connections from your history or disable it entirely.)
- Alternate actions:
- Open connection with mosh instead of SSH.
- Open SFTP connection instead of SSH.
- Ping host.

This started as a straight port of [@isometry's][isometry] Python [SSH workflow][ssh-breathe] to Go as a testbed for the language and a Go workflow library. It has since been ported to Alfred 3 only, and gained some additional features.


Installation
------------
Expand All @@ -35,38 +33,53 @@ Keyword is `ssh`:
- `` or `⌘+<NUM>` — Open the connection.
- `` — Expand query to selected connection's title. Useful for adding a port number.
- `⌘+↩` — Open an SFTP connection instead.
- `⌘+⌥` — Open a mosh connection instead.
- `⇧+↩` — Ping host.
- `⌥+↩` — Forget connection (if it's from history).
- `^+↩` — Forget connection (if it's from history).


### Configuration

There are several options available in the workflow's configuration sheet. Notably, you can turn off individual autosuggestion sources.

| Variable | Description |
|:----------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `DISABLE_ETC_HOSTS` | Set to `1` to turn off suggestions from `/etc/hosts`. |
| `DISABLE_KNOWN_HOSTS` | Set to `1` to turn off suggestions from `~/.ssh/known_hosts`. |
| `DISABLE_HISTORY` | Set to `1` to disable the History (reading and writing). |
| `EXTERNAL_TRIGGER` | Set to `1` to re-open Alfred via an External Trigger instead of a direct AppleScript call. The External Trigger is safer, but leaves Alfred in a weird mode. |
| Variable | Description |
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `DISABLE_CONFIG` | Set to `1` to turn off suggestions from `~/.ssh/config`. |
| `DISABLE_ETC_CONFIG` | Set to `1` to turn off suggestions from `/etc/ssh/ssh_config`. |
| `DISABLE_ETC_HOSTS` | Set to `1` to turn off suggestions from `/etc/hosts`. |
| `DISABLE_HISTORY` | Set to `1` to disable the History (reading and writing). |
| `DISABLE_KNOWN_HOSTS` | Set to `1` to turn off suggestions from `~/.ssh/known_hosts`. |
| `EXIT_ON_SUCCESS` | Set to `1` (default) to close shell if `ping` or `mosh` command exits cleanly |
| `EXTERNAL_TRIGGER` | Set to `1` to use an External Trigger instead of AppleScript to re-open Alfred. The External Trigger is safer, but leaves Alfred in a weird mode. |
| `MOSH_CMD` | Set to the full path to `mosh` if your shell can't find it. Set to empty to disable `mosh` connections. |


**Please note**: The workflow generates an `ssh://` (or `sftp://`) URL and asks Alfred to open it. Similarly, the `ping` and `mosh` features uses Alfred 3's Terminal Command feature. If it's not opening in the right app, it's not the workflow's fault.


**Please note**: The workflow simply generates an `ssh://` (or `sftp://`) URL and asks Alfred to open it. Similarly, the ping function uses Alfred 3's Terminal Command feature. If it's not opening in the right app, it's not the workflow's fault.
Licencing & thanks
------------------

This workflow is released under the [MIT Licence][mit].

It uses the following libraries and resources:

Licence
-------
- The icon is based on [Octicons][octicons] by [Github][gh] ([SIL Licence][sil]).
- [ssh_config][ssh_config] ([MIT Licence][mit]) to parse SSH config files.
- [awgo][awgo] ([MIT Licence][mit]) for the workflowy stuff.

This workflow is released under the [MIT License][mit].
This workflow started as a port of [@isometry's][isometry] Python [SSH workflow][ssh-breathe] to Go as a testbed for [awgo][awgo]. It has since gained some additional features.

The icon is based on [Octicons][octicons] by [Github][gh], released under the [SIL License][sil].
If you need Alfred 2 support, check out [@isometry's workflow][ssh-breathe].


Changelog
---------

- v.0.5.0 — 2016-10-31
- Add support for SSH configuration files (`~/.ssh/config` and `/etc/ssh/ssh_config`)
- Alternate action: open connection with `mosh`

- v0.4.0 — 2016-05-27
- Add ability to turn sources of suggestions off #1

Expand All @@ -80,11 +93,13 @@ Changelog


[alfredapp]: https://www.alfredapp.com/
[awgo]: https://godoc.org/gogs.deanishe.net/deanishe/awgo
[demo]: https://raw.githubusercontent.com/deanishe/alfred-ssh/master/demo.gif
[octicons]: https://octicons.github.com/
[gh]: https://github.com/
[gh-releases]: https://github.com/deanishe/alfred-ssh/releases/latest
[gh]: https://github.com/
[isometry]: https://github.com/isometry
[ssh-breathe]: https://github.com/isometry/alfredworkflows/tree/master/net.isometry.alfred.ssh
[mit]: https://raw.githubusercontent.com/deanishe/alfred-ssh/master/LICENCE.txt
[octicons]: https://octicons.github.com/
[sil]: http://scripts.sil.org/OFL
[ssh_config]: https://github.com/havoc-io/ssh_config
[ssh-breathe]: https://github.com/isometry/alfredworkflows/tree/master/net.isometry.alfred.ssh
Binary file removed Secure-SHell-0.4.1.alfredworkflow
Binary file not shown.
Binary file added Secure-SHell-0.5.alfredworkflow
Binary file not shown.
Loading

0 comments on commit ba3fdc7

Please sign in to comment.