List and connect to your Digital Ocean droplets instantly (without a .ssh/config)
go get github.com/theonejb/dropletconn
go install github.com/theonejb/dropletconn
dropletconn config
dropletconn list
dropletconn connect <NAME OF DROPLET>
To use, go get github.com/theonejb/dropletconn
and go install github.com/theonejb/dropletconn
. dropletconn
is the
name of the genrated binary. I personally have it aliased to dc
using export dc=dropletconn
in my .zshrc
file since
I use it atleast 20 times a day to connect to various servers at work.
You will also need to generate a token from Digital Ocean API Tokens
that dropletconn
will use to get a list of droplets available in your account. For safety, use a Read only scoped token.
Available commands and their usage is described here. Some commands have a short version as well, which is what you see after the OR pipe (|
) in their help text below.
config
: Generate config file that stores the API token and other settings. This needs to be generated before the rest of the commands can be usedlist | l [<FILTER EXPRESSION>]..
: Lists all droplets from your account. You can optionally pass a number of filter expressions. If you do, only droplets whose names or IPs contain at least one of the given fitler expressions will be listedconnect | c NAME
: Connect to the droplet with the given namerun | r <FILTER EXPRESSION> <COMMAND>
: Runs the given command on all droplets matching the filter expression. The filter expression is required, and only one filter expression can be given
You can pass an optional --force-update
flag. By default, the list of droplets is cached for a configurable duration (as set in
the config file). Passing this flag forces an update of this list before running the command.
The list
command also accepts an options --list-public-ip
flag. If this flag is used only the public IP of the nodes is printed, nothing else.
This is incase you want a list of all IPs in your DO account. I needed this to create a Fabric script.
Note: The way flags are parsed, you have to list your flags before your commands. For example, you can not do dropletconn list --list-public-ip
.
Instead, you need to do dropletconn --list-public-ip list
. Same for the --force-update
flag.
To enable completion of droplet names, source the included Zsh completion file. Credit for that script goes to James Coglan. I copied it from his blog (https://blog.jcoglan.com/2013/02/12/tab-completion-for-your-command-line-apps/).