DEV Community

olistik
olistik

Posted on

3 1

Show the hosts configured in your SSH config file

Recently I had to connect via SSH to several hosts. It's hard for me to remember their full domain, not to mention all the options required (identity file, port, etc.) to connect.

The SSH config file (~/.ssh/config) is the best place to store this information but then again I have to remember all the name I used for such hosts..

No memory

To make my life even more comfortable, I created this little Ruby script that shows a sorted list of the hosts present in the SSH config file:

Behold! 🧙🏼‍♂️

#!/bin/zsh

cat ~/.ssh/config | ruby -e "puts STDIN.each_line.map {|l| l.match(/^Host\ (.*)$/)}.compact.map {|r| r[1]}.sort"
Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay