Linux CLI Connect Manager?

6,765

Solution 1

What about using the ~/.ssh/config file? Easy to use, maintain and share with others. If you need to share it then a Git repository for it would be perfect.

The file looks like this:

Host somename
  User username
  HostName 192.168.1.X
  Port 2222

Man ssh_config for more options.

Solution 2

Here is some code from my .zshrc file. It will auto complete the hosts from /etc/hosts, a list you can manage, and those you have connected to before (if you have 'HashKnownHosts no' set in your ssh config). Setting 'HashKnownHosts no' could be considered a security risk because users that already have access to your $HOME/.ssh/known_hosts file could see the systems you have connected to before. This was stolen from grml configs.

if is42 ; then
    [[ -r ~/.ssh/known_hosts ]] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
    [[ -r /etc/hosts ]] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
else
    _ssh_hosts=()
    _etc_hosts=()
fi
hosts=(
    $(hostname)
    "$_ssh_hosts[@]"
    "$_etc_hosts[@]"
    example.com
)
zstyle ':completion:*:hosts' hosts $hosts

After adding that everything works like magic.

Share:
6,765

Related videos on Youtube

Mike M
Author by

Mike M

Updated on September 18, 2022

Comments

  • Mike M
    Mike M almost 2 years

    I am looking for a connection manager for Linux that runs in the CLI. To be clear, by connection manager I mean a program that allows you to create, save, and quickly launch remote connections. Similar to mRemote, mRemoteNG, Vrd, Terminals, Devolutions RDM, etc. You should be able to define a connection type (ssh), destination (IP or DNS), and paramerts such as SSH version, username/password, etc

    We are in the process of tightening up security in a large manager service provider environment and will be creating a couple of "hop-off" linux boxes. The idea is that our team and level 1 support will SSH to those linux servers, and then from there connect to various pieces of network equipment throughout the environment. It is both more secure and required because of some of the routing (VRF's) in place.

    Ideally I am hoping that solution stores connection in mySQL or similar so that we can easily access one library of connections from multiple machines (hop-off boxes).

    Has anyone encountered a program or project like this? I have found a few apps for Linux, such as Remmmina, Monocaffe, and PAC Manager, but they are all GUI. I don't want to have to VNC into the hop off boxes since we only need CLI for SSH anyway.

    Thanks!

  • Rob
    Rob over 12 years
    I'm setting mine up like this and removing my aliases.
  • ggustafsson
    ggustafsson over 12 years
    I used aliases too but it's a real hassle. The ssh config works great. I'm lazy so i have this: "for X in $SSH_HOSTS; do alias $X="ssh $X" done" in my ~/.zshrc file so i can just type the hostnames without the "ssh" part :)
  • ggustafsson
    ggustafsson over 12 years
    Oops.. Forgot the most important code "[ -f ~/.ssh/config ] && SSH_HOSTS=($(sed -ne 's/^Host //p' < ~/.ssh/config))" parses the ~/.ssh/config file :)