88 points · by nsxwolf · 8y ago · 98 comments
My system for keeping all this organized is to sift through bash history and browser history and abortive attempts at keeping Excel spreadsheets or Evernote pages full of this stuff.
Does anyone have any pointers for tools they like to make this easier?
Thanks!
[0] https://www.digitalocean.com/community/tutorials/how-to-conf...
Cygwin does a good job with the ssh config file on Windows, if anyone is looking for tool suggestions.
This wasn't in OPs question, but have to add that if possible, put your SSH keys in the servers known_hosts file and you can have secure passwordless login, which combined with the ssh config file on your machine is fantastic. I just do "ssh $SERVER" in cygwin, where $SERVER is my defined alias pointing to an IP, and that's it. Takes literally five seconds.
https://github.com/Comcast/ssh-to
I'm responsible for a few hundred servers at this point, and the tool has scaled nicely for connecting to them, and occasional "run this one-off command across a series of servers". (But if it's more than once, you'll seriously want to use Ansible for that...)
paul@ubuntu:~/src/wimo$ brew tap comcast/opensource github.com:Comcast/homebrew-opensource.git ==> Tapping comcast/opensource Cloning into '/home/paul/.linuxbrew/Library/Taps/comcast/homebrew-opensource'... Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Error: Failure while executing: git clone github.com:Comcast/homebrew-opensource.git /home/paul/.linuxbrew/Library/Taps/comcast/homebrew-opensource --config core.autocrlf=false --depth=1
So, I just plopped the ssh-to shell script into my ~/bin folder.
Why are you using Homebrew on Ubuntu? Homebrew is a MacOS package manager.
URLs for environments sound like application-related documentation and could be part of a Readme file the app repository.
You can configure custom url handlers so that it opens the terminal then ssh right in the server you clicked on.
With a firefox extension, it let you autofill credentials.
Simple one file to backup or sync. Always encrypted. Crossplateform. Free software. Robust. Proven. And a Fugly UI that looks corporate enough for you pointy hair boss.
The only thing missing is that I'm using a cmd otp generator for one time passwords, but it doesn't have keepass support yet.
Otherwise pointy hair boss will bitch.
SSH: autocomplete using known_hosts so I can easily tab complete any server name I've SSH'ed to in the past.
Web: Just bookmarks OR Environment Handbook pages on a wiki
Ssh - ssh config named as <system>_<environent>
rest APIs - postman collections by system
Although, my work recently took away direct SSH access for all devs in all environments, we now have to SSH to a bastion host, then SSH to servers from there. Makes my ssh config less valuable.
# Sample bastion host configuration without ForwardAgent
# Host bastion
# User bastion_user
# Hostname 10.11.12.13
# IdentityFile ~/.ssh/id_bastion
#
# Host server
# User server_user
# Hostname 192.168.0.1
# IdentityFile ~/.ssh/id_server
# ProxyCommand ssh -q -W %h:%p bastionFor URLs, you can use bookmarks or a custom homepage.
For example, you can enter 'prod region1 bestservice' to interactive open the URL.
Here is the script:
#!/usr/bin/env fish
function +fzf_open_url
[ -z "$FZF_OPEN_URL_LIST" ]; and echo "Please configure \$FZF_OPEN_URL_LIST first." >&2; and return
set -l result ( \
cat $FZF_OPEN_URL_LIST \
| sort \
| uniq \
| grep -ve '^$' \
| fzf --bind "enter:execute-silent:open {}" \
)
end
Gist: https://gist.github.com/hktonylee/ca56920dd0323c1c40726764d1... Host $company-$project-$location-$server
HostName $IP
Host *$company*
# Gateway Settings
You can specify specific configs first, then have them waterfall down to general configs. This allows you to customize usernames, identity files, proxies etc. This file is known to fish autocompletions so I can just do `ssh` and use tab completions until I have all the pieces filled. I also use a socks proxy by specifying `-D $port` so I can access the server from inside Firefox with a network config (I use firefox solely for separate socks proxy access to avoid having to proxy all data in OSX system prefs. Not sure if Safari has that ability).- 1Password for teams is awesome. It has first-class support for things like database connections, credit cards, etc. You can also add custom fields to any object. It's a great way to share things with your team.
- I use .ssh/config to store my SSH connections with names I can easily remember.
- In Chrome, I have a few links in the bookmark bar. I open a new tab and click once to get my calendar, email, JIRA, etc. Things I use multiple times a day and usually open first thing in the morning.
- Documentation in Github repos, usually on the main README. This is for things like staging URLs.
I do sometimes rely on bash/browser history, but I always have everything I use in one of those four places.
For instance for ssh I use a small combo wrap 'ot' (open tab(s)) that opens a terminal tab and parses my args to start terminal tab batches of ssh sessions. Your wrap could be as simple or complex as you need. I parse my args as necessary like:
ot lead1(app) lead2(envid) [lead3(tier)] [lead4(instance/role)]
as so: cmdprmpt% ot coolapp dev1 app app1 # will open a single term tab to the coolapp app tier instance 1
leaving off the instance/role will open a tab session to each instance (ot coolapp dev1 db) leaving off the tier will open a tab to each node on every tier for that app env (ot coolapp dev1) leaving off the envid doesn't work because that would just be a lot of tabs.
Barring that type of approach aliases are definitely your friend. The same could be done for opening browser sessions and/or curl/wgets whatever etc..
Barring that and for anything over, say, 100 targets (or excruciatingly non-deterministic target names) I'd probably have a single file with a bunch of key pairs and wrap against that (or some sort of wee db for 1000's).
An example of an overlay, though not aimed at environments specifically:
https://plus.google.com/104092656004159577193/posts/ASRaMF5x...
There used to be a "Domain Switcher" extension for Firefox, but it doesn't seem to work in a post-Quantum world. Chrome has such a addon: https://chrome.google.com/webstore/detail/domain-switcher/lb...
I can't stress enough the importance of doing this - using either this tool, or something similar (like manually managing ssh agents).
Using one key only would mean that any server you ssh to has (assuming you forward the ssh auth/roaming) the ability to "forward" that connection, and do evil things with it. See https://blog.filippo.io/ssh-whoami-filippo-io/ for more about it.
Having multiple keys and only using an agent with the "right" key for the "thing" mean that each "thing" you SSH to would, in the above scenario, not be able to inflict any damage at all.
That is, ssh'ing into your personal dev box wouldn't give the dev box access to your work github account.
It's not "easy" to use ssh-ident, or create and remember which identities should be used where, but it's IMVHO easy _enough_.
If anyone knows of a better tool, or a better method, I'm all ears. I've thought about using multiple yubikeys or the like, but all methods I've so far found fall very, very short on usability.
~/.ssh/config
is really simple, I never needed anything else.For URLs, I use bookmarks, that's it. You might actually need more, or you might think you might need more :D but I don't think so.
Also different URL collections have different places, for example I collected all our developer documentation URLs in a single wiki (Confluence) page with a permalink and put it under an easy-to-remember internal domain.
If you get NXDOMAIN on bar.foo.cats, you'll know there's no integration-server for that project. If you want to move to a different server, you update your DNS records, not your deploy-scripts. If you want to change the public name of a service you can do it without changing anything about how you access it.
Others have mentioned .ssh/config which is one piece of the puzzle. I have shorthands named bar-int, bar-stage, bar-live that point to the respective domains. We work towards having all SSH usernames being the same as the project shorthand. At that point the SSH aliases can be generated automatically from a list of projects.
It replaces the "new tab" page. Basically it's an organized grid of links by category. A chrome extension lets you add bookmarks.
I built it for myself, and then I put the stripe api on top of it. (No users though :/)
If you have an issue tracking or code review system you customize it so you can do "go/T123" and go to issue "T123". Or for common apps you can put in place simple patterns like "go/foo/id" and it opens that application to looking at that id.
It reads in a YAML config file and allows you to shorten URLs, with recursive expansion.
For example: https://subdomain.corp.company.com/staging --> http://s/staging, or even http://s/s
The nice thing with Zap is you don't need to click through bookmarks, and you only need to sync one file. There's also useful info in the README on how to set this up on your internal DNS server.
When in doubt, write it down, preferably somewhere secure to prevent leaking anything if handling sensitive data. Excel spreadsheets work pretty well too, but formatting might get a bit distracting.
At a previous job we ran a lot of client-facing servers and kept most of the URLs in our server monitoring software. It wasn't great and there wasn't a lot of documentation, but frequently accessed servers were all in a central place (save for our test/Ansible servers).
The credentials themselves - in a shared KeePass2 KDBX (with the KeePassHTTP extension for filling or the ability to press Ctrl+U), so that anyone can add or modify entries when needed.
For SSH, using KeePass2 + KeeAgent to serve SSH keys. If there are too many then again using Ctrl+U to launch a bash terminal with the ssh command and the corresponding path to which the temp key gets written.
For SSH endpoints, I more or less have everything aliased in my ~/.ssh/config file. If it's just a server, I can just ssh hostname. If it's a host I'm doing port forwarding on, I'll have it aliased to ssh hostname-tunnel or ssh hostname-SOCKS5.
Note that you can specify remote user, details such aas crypto protocols, and many shell-completion tools autoexpand these.
Highlighting host and username in shell propmts also helps.
Webpages / URLs: bookmarks, though I'm relying increasingly on an old-school homepage, written in Markdown (or pick your alternative LWML) managed in git, and published via Makefile.
For team efforts, this in a Wiki, though with easy edit access. I increasingly prefer distict authoring/reading environments. That is, shell tools (vim, emacs, pandoc, make, git, etc.) for authoring, browser to read.
For ssh I just use bash history, but I don’t have a ton of environments
You can also share your resource lists as well if this is a team wide issue for you.
Simple rule of life if you ever do something a second time turn it into a script.
So if I need to check the production nameserver it's ns-pdap-01.internal.tld and so on.
[0] https://www.racktables.org/ [1] https://github.com/digitalocean/netbox
The bookmarks app available in NextCloud is suppose to sync across browsers (with extension for each browser), though I only use Firefox these days, and it can sync stuff across devices out of the box of course.
From what I’ve seen it was a little bit confusing, since it’s seem to ass it’s own prefix and the UI in NextCloud is not very interesting. Still, might worth you while checking.
I built a database on AWS DynamoDB + API Gateway which has the "url" information. Also many other things, like which newrelic accounts are used by each environment. This is intended to be used by automation, but humans can just curl | jq these.
That said, SSH access (by humans) should be very rare. If you have to SSH to a production system, ask yourself what is it that you are trying to accomplish, and would you still be doing that if you had another tool to accomplish the same operation?
environments/
development/
readme.md
services/
service1/
readme.md
service2/
readme.md
preproduction/
...
production/
...
And store that in a git repository and publish it. We're starting to look at documentation generation tools (like Sphinx and readthedocs) to help make a pretty website for endusers.1) As others have already written, I use ssh config to organize the urls and have simpler host names.
2) I use 2/3 letter codes as aliases which ssh into the specific host.
For ex- Environment - tool
sw = staging webserver pw = production webserver pj = production jenkins.
This allows me to open a new terminal window and type 2/3 characters to ssh into a box.
On windows I use mRemoteNG https://mremoteng.org/
On mac I use YummyFTP https://www.yummysoftware.com/
SSH: ~/.ssh/known_hosts and ~/.ssh/config
Web URLs - Use bookmarks or write yourself a small local html file with a bit more organisation. Or use a text file with an editor that makes it easy to Cmd+Click a link.
Less simple, but great for teams, use a wiki page with the appropriate links.
I find chrome bookmarks sufficient for my website bookmarks. They sync across computers and can be organized in folders.
I've never really understood how you should keep SSH keys. I kept them all in a folder and set zsh to iterate through them all and run ssh-add on startup. Until I realised it can't cope after adding a certain amount, now I'm back to manually doing it.
Edit: autocorrect
Windows: mRemoteNG
Linux: Gnome connection manager
Mac: Iterm 2 profiles (any better options?)