EndPointCorp / end-point-blog

End Point Dev blog
https://www.endpointdev.com/blog/
17 stars 65 forks source link

Comments for SSH config wildcards and multiple Postgres servers per client #394

Open phinjensen opened 7 years ago

phinjensen commented 7 years ago

Comments for https://www.endpointdev.com/blog/2011/01/ssh-config-wildcards-and-multiple/ By Greg Sabino Mullane

To enter a comment:

  1. Log in to GitHub
  2. Leave a comment on this issue.
phinjensen commented 7 years ago
original author: David Christensen
date: 2011-01-07T12:33:11-05:00

This sounds very useful; in particular, I hadn't known about the wildcard facility, which will simplify my own .ssh/config file.

I've found myself coming up with the naming convention for entries along the lines of: client-server-role, which sounds like it would work well with the approach you're describing. I personally think using wildcards with a standard delimiter such as "-" would make accidental wildcard expansion less likely, so maybe something like: acme-dev-p with the wildcards adjusted to account for the literal "-" as boundaries; i.e., "-p" instead of just "p".

This would make the config a little more robust and prevent accidental expansion/inclusion of substrings that matched unexpectedly, and just make it a lot easier to be more confident when dealing with a lot of entries that everything is getting expanded/handled as you expect.

Thanks for writing this,

David

phinjensen commented 7 years ago
original author: HarleyPig
date: 2011-01-07T15:28:01-05:00

I knew about the wildcards but I didn't realize how powerful they could be.

I use the following in my .bash_aliases file which has the benefit of reducing 'ssh acmedev' to 'acmedev' on the commandline, plus I get bash-completion automatically.

if [ -e ~/.ssh/config ] then

I'm always in screen on my systems.

echo -e "\ekHostname\e\" will change the screen title for that tab to the hostname

pre_title='echo -e "\ek' post_title='\e\" && ssh' reset='&& echo -e "\ekbash\e\"' screen='-t screen -RDl'

for i in $(grep -E '^Host [^*]' ~/.ssh/config | cut -d ' ' -f 2) do alias $i="${pre_title}$i${post_title} $i ${reset}" done

fi

I'm going to have revisit this to handle wildcards though ...

phinjensen commented 7 years ago
original author: Greg Sabino Mullane
date: 2011-01-07T21:19:08-05:00

David: yes, but I am not worried about typos, and the dashes are more characters to type out. I've got most client servers down to four or five character abbreviations, and my fingers and brain are very trained in recalling them. :)

phinjensen commented 7 years ago
original author: Greg Sabino Mullane
date: 2011-01-07T21:22:12-05:00

HarleyPig: that is very cool. I've got a bunch of aliases, but never thought about simply auto-generating them all at once. Because the wildcards are pretty standard, I think it won't be too much of an issue - maybe just hard code in the username options as separate aliases.

phinjensen commented 7 years ago
original author: maletin
date: 2011-01-07T22:19:00-05:00

I'm sure you love the ssh -L option to tunnel the Port 5432.

phinjensen commented 7 years ago
original author: Greg Sabino Mullane
date: 2011-01-07T22:53:53-05:00

maletin: I love it, but honestly I've used it very infrequently. Very handy for transferring local data to and from a remote database.

phinjensen commented 7 years ago
original author: Joshua Tolley
date: 2011-01-07T23:32:35-05:00

While we're expanding into other ssh options, my favorite is -D, which creates a SOCKS4/5 proxy for dynamic tunneling through the ssh connection

phinjensen commented 7 years ago
original author: Tometzky
date: 2011-01-10T12:43:58-05:00

There should be no colon (":") in these, so instead of:   Host: acmecorp   User: postgres It shoud be:   Host acmecorp   User postgres

phinjensen commented 7 years ago
original author: Greg Sabino Mullane
date: 2011-01-10T12:52:51-05:00

Tometzky: Thank you, now fixed. Too much editing of postgresql.conf files!