add an example script to connect via SSH - iomenu - interactive terminal-based selection menu
(HTM) git clone git://bitreich.org/iomenu git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/iomenu
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit 1590da77cec0108488d80044219e8a6a12f2538d
(DIR) parent 0332f4dd490ea3fe6421a8f064142c3747938653
(HTM) Author: Josuah Demangeon <me@josuah.net>
Date: Tue, 21 Dec 2021 10:49:43 +0100
add an example script to connect via SSH
Diffstat:
A bin/iomenu-ssh | 10 ++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/bin/iomenu-ssh b/bin/iomenu-ssh
@@ -0,0 +1,10 @@
+#!/bin/sh -eu
+# SSH connect to a host in ~/.ssh/known_hosts and /etc/hosts
+
+etc_hosts=$(awk '/^[ \t]*[^#]/ { for (i = 2; i <= NF; i++) print $i }' /etc/hosts)
+known_hosts=$(awk '{ print $1 }' "$HOME/.ssh/known_hosts")
+host=$(printf '%s\n' $etc_hosts $known_hosts | sort -u | iomenu)
+
+test -n "$host"
+
+ssh "$host"