

Show HN: S – a tool for ssh like z for cd - haosdent
https://github.com/haosdent/s

======
jethro_tell
It's amazing to me how many people use ssh and don't have an ssh config. It
would be easier to maintain a .ssh folder in version control then to install
this on each host and ssh until it learns.

Your auto provision of servers with chef or puppet should be adding them to
you .ssh/config with a pointer to the ssh key and special requirements like
tunnels through jump hosts/ bastion hosts.

~~~
dhagz
Are there any resources you recommend on maintaining a .ssh folder? I've done
a little reading, but I've never really needed to worry about working with
multiple servers before, but I'm going to need to learn soon for a project at
work.

~~~
voltagex_
My set up dotfiles in a git repo (~/configs) with a Makefile that symlinks
them to the correct location.

I'm hoping someone chimes in with a bit of a better solution but there's no
reason you couldn't have ~/.ssh/config symlinked in the same way.

Make sure you know which version/s of ssh you'll be dealing with and make the
config work with the lowest version

Some HN articles/discussions:

[https://news.ycombinator.com/item?id=4677049](https://news.ycombinator.com/item?id=4677049)

[https://news.ycombinator.com/item?id=7658459](https://news.ycombinator.com/item?id=7658459)

Some stuff changed in OpenSSH 6+ so read the manpages, too.

~~~
bdarnell
There is actually a reason you can't have ~/.ssh/config symlinked the same
way: ssh refuses to read a symlink for this file (for security purposes it is
strict about the file type and permissions). My workaround is to copy the file
instead of symlinking in my dotfile-setup script.

~~~
wampus
I version control the entire directory (ignoring the known_hosts file)
somewhere like ~/config/ssh and symlink it to ~/.ssh. It contains a Makefile
with a target that runs this command:

    
    
        ln -s ${PWD} ~/.ssh
    

Just make sure the directory is chmod 700 and the important files in it are
chmod 600.

~~~
jethro_tell
Also ignore any private keys. For security, but also each host should have a
different key so you can burn one without burning them all.

------
wampus
Just my 2 cents, but I feel strongly that publicly released programs should be
named with a minimum of 3 characters, reserving shorter names for user aliases
and local commands.

------
_jomo
This is nice, but I also like the way fish
([http://fishshell.com/](http://fishshell.com/)) handles auto-completion:

When I type `ssh<tab>`, I get a list of hosts from my ~/.ssh/config plus hosts
I have previously used.

I can actually use `ssh hn<tab>` and it gets auto-completed to `ssh hostname`
because "hostname" is configured in my ssh config. The same works for `ssh
user@<tab>`

~~~
jamiesonbecker
fwiw, bash autocompletion does this automagically, too, but you might need to
enable it. .ssh/config is definitely the canonical place to keep this stuff,
but I like @haosdent's ranking concept. some of my boxes I rarely log into,
and others I log into all the time.

------
chainsaw10
I had to look up what z for cd was, so to save others the trouble, here's a
link (hopefully the original...):

[https://github.com/rupa/z](https://github.com/rupa/z)

SSH hosts tend to be long, so this seems like a good idea. I realize the
.ssh/config exists, but this doesn't require setup per server.

~~~
jethro_tell
> but this doesn't require setup per server.

Well you have to ssh to the serer a few times?

------
jamiesonbecker
Userify supports jump box creation[1] (automatic .ssh/config coming soon as
well) and with bash autocompletion, you can hit any host in .ssh/config.

Is there any way to add ranking variables to .ssh/config that a regex or
autocompletion script like this could read but plain SSH would ignore? 'bad
configuration option' if I stick in an unrecognized variable name. Embed in
comments?

1\.
[https://userify.com/docs/tips/jumpbox/](https://userify.com/docs/tips/jumpbox/)

~~~
haosdent
I think we could add rank like this:

Host xxx

    
    
        Rank 2

------
chrift
Wouldn't you just use vssh and be done with it?
[http://www.velestar.com/Pages/VSSHOSXPage.aspx](http://www.velestar.com/Pages/VSSHOSXPage.aspx)

Or am I missing the point?

------
shadeless
Nice! I use warp [0] to manage ssh hosts, but I could see myself using this
too.

[0] [https://github.com/jpalardy/warp](https://github.com/jpalardy/warp)

~~~
haosdent
Looks nice!

------
fasteo
I usually do "CTRL-r ssh" to accomplish this. Maybe not as complete, but
enough for me.

------
jamiesonbecker
this is fantastic work @haosdent - I'm working on adding automatic .ssh/config
generation to Userify shortly. Could this read .ssh/config and build initial
db for that?

~~~
haosdent
Let me try :-)

------
haosdent
s is a tool for ssh like z for cd

~~~
p4lindromica
just like there is .ssh/config for ssh, there is $CDPATH for cd.

