Giter Club home page Giter Club logo

sshto's People

Contributors

mattdonders avatar pforret avatar stalldandelion avatar vaniacer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sshto's Issues

declare: -A: invalid option

hi,

there are some errors when running on macOS

./sshto
./sshto: line 479: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
./sshto: line 566: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
./sshto: line 568: ${name,,}: bad substitution

Thanks

Don't load include config

I have a file ~/.ssh/config with the following content
Include conf.d/dbofl.config Include conf.d/my.config Include conf.d/fap.config
And sshto doesn't handle include files

Add a license

Hi, there is no license included, and by default it means it cannot be used/copied/shared.

support for VirtualBox

Is it possible to use sshto from a Virtualbox client installation?
After running sshto, only the contents of the current directory is printed.

uname -a
Linux roku 5.13.0-37-generic #42-Ubuntu SMP Tue Mar 15 14:34:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

hostnamectl
Static hostname: roku
Icon name: computer-vm
Chassis: vm
Machine ID: 6c4529d835e546e4b96a3758071e0488
Boot ID: 1fb57395bda747cf8062c1dc6a0a3763
Virtualization: oracle
Operating System: Ubuntu 21.10
Kernel: Linux 5.13.0-37-generic
Architecture: x86-64
Hardware Vendor: innotek GmbH
Hardware Model: VirtualBox

locale
Linux roku 5.13.0-37-generic #42-Ubuntu SMP Tue Mar 15 14:34:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
LANG=cs_CZ.UTF-8
LANGUAGE=cs:en_US
LC_CTYPE="cs_CZ.UTF-8"
LC_NUMERIC="cs_CZ.UTF-8"
LC_TIME="cs_CZ.UTF-8"
LC_COLLATE="cs_CZ.UTF-8"
LC_MONETARY="cs_CZ.UTF-8"
LC_MESSAGES="cs_CZ.UTF-8"
LC_PAPER="cs_CZ.UTF-8"
LC_NAME="cs_CZ.UTF-8"
LC_ADDRESS="cs_CZ.UTF-8"
LC_TELEPHONE="cs_CZ.UTF-8"
LC_MEASUREMENT="cs_CZ.UTF-8"
LC_IDENTIFICATION="cs_CZ.UTF-8"
LC_ALL=

dialog --version
Version: 1.3-20201126

bash: Server: command not found

I'm sure this is a user error, but I can't find a solution for it. I have (1) Ubuntu server that I created an sshto entry for in my config file. Its' entry is simply: hostname (ip address), user remote user account), port 22. That is it. When I execute it, I am prompted for a password, which I enter and then I get "bash: Server: command not found" and the next key press closes the session. If I go to a command prompt and try ssh (username)@(ip address), enter the same password, I get a command prompt. Any idea what is causing my issue?

Thanks!
Jon

Feature Request: tmux/screen title renaming

If the user is using sshto in tmux or GNU screen, dynamically re-title the window to the hostname that we are connecting to. Upon disconnect, revert to previous title.

I've tried to get this working locally, but wasn't happy with the results.

Add MacOS Compatibility

Just found this script (exactly what I've been looking for) & running this on MacOS and I found the following two issues that I can fix via PR if you'd like.

  1. If dialog not installed on the system, the script recommends I run the command sudo apt-get install -y dialog where I use brew install dialog on my MacOS system.

  2. When you exit the dialog, you get the following error due to the ls --color=auto command.

ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]

Let me know if you'd like me to code up these fixes using uname -s detection of a MacOS system.

Thanks!

Add Optional Tags to Change Behavior for Specific Host

I'm looking for a way to add optional tags to a host and have sshto act on those tags.

Specifically, in my environment I have certain hosts that are live and hosts used for testing, as most people probably do. One of the fast ways I differentiate this is by making the background color of the production hosts different from non-production hosts, and I use a kitty browser kitten to do this.

What I'm now trying to do is add a tag to the end of a host description in an sshconfig file, say Host prod_serv #Production Server#PROD and then have sshto run a different ssh command when it sees that PROD tag. Where I'm running into trouble is I can't quite figure out how to make sshto see the tag or created variable when go_to_target() is called. Below is what I have so far, and any suggestions or advice you can provide is greatly appreciated. I couldn't find a way to highlight the specific lines I added, so the edited portions in the second code block are preceded with four underscores (____). Please be forewarned I'm no programmer so it would not surprise me to learn I'm approaching this all wrong.

Edit: I suppose I should have included what behavior I'm seeing now. It does not identify the $prod variable in the go_to_target function and so always executes the else statement. In the past I've just put all production servers in the same group and used the $group_name in the if/else statement, but I'd like to get away from having to keep unrelated production servers in the same group.

#------------------------{ SSH to target server }-----------------------------------------------------------------------
go_to_target(){ clear; 
  if [[ $prod == *"PROD"* ]]; then
   kitty +kitten ssh $SSH_OPT $target || pause;
  else
   ssh $SSH_OPT $target || pause;
  fi
}

.
.
.
.

#-------------{ Create the list of hosts. Get hosts and descriptions from ~/.ssh/config* }------------------------------
desclength=20
declare    -A      hostnames
____declare    -A      hostnames_prod
while read -r name hostname desc; do
    case    ${name,,} in
        'group_name') name="{ $desc }"
                      name_length=${#name}
                      name_left=$[(40-name_length)/2]
                      name_right=$[40-(name_left+name_length)]
                      printf -v tmp "%${name_left}s_NAME_%${name_right}s"
                      tmp=${tmp// /-}  name=${tmp//_NAME_/$name}
                      content+=( "$desc" );  desc='_LINE_';;
                '#'*) continue;;
    esac
    ((${#desc}>desclength)) && desclength=${#desc}
    hostnames["$name"]=$hostname #Create host-hostname pairs in hostnames array
    ____hostnames_prod["$name"]=$prod
    fullist+=("$name" "$desc")   #Add Host and Description to the list
done < <(gawk '
BEGIN{IGNORECASE=1}
/Host /{
    strt=1
    host=$2
    desc=gensub(/^.*Host .* #(.*)/, "\\1", "g", $0)
    ____prod=gensub(/(.*)(#PROD$)/, "PROD", "g", desc)
    desc=gensub(/(.*)#.*/,          "\\1", "g", desc)
    # desc=gensub(/(.*)#PROD$/, "\\1", "g", desc)
    next
}
strt && host == "dummy"{
    hostname=$2
    print "group_name", "dummy", desc
    strt=0
}
strt && /HostName /{
    hostname=$2
    print host, hostname, prod, desc
    strt=0
}'  $CONFILES)

descline=$(line - $desclength)
list=( "${fullist[@]}" )

Multiple 'Host' aliases are not handled gracefully

In the SSH config file, multiple space-separated entries on the Host line can resolve to the same set of configuration options. For example:

Host pear peach plum 
     Hostname %h.orchard.gardenparty.org
     user farmer
     IdentityFile ~/.ssh/id_rsa_orchard_20240109

In this case there are three different hostnames our farmer@ might want to get connected to with this private key and other settings. But sshto will only show the first host, pear, leaving no way within sshto for the user to connect to host peach or plum.

This is an enhancement request to render those space-separated aliases on the Host line as individual hosts.

One possible workaround would be for the user to manage a (far more verbose) .ssh/config file with a separate identical entry for each host. The challenge there is it would hamper adoption from users who have a maintained their config file manually, efficiently so far.

Another consideration is there are wildcard options for both the Host and Hostname parts of the configuration here that could expand beyond what sshto could possibly know from the config file, potentially making a need for another interactive dialog.

Doesn't work with possible uses of Include keyword

sshto doesn't use configuration files included in .ssh/config.

Example setup:

❯ cat ~/.ssh/config
Include ananas/config
Include github/config
# blah-blah

/tmp
❯ cat ~/.ssh/github/config
# vim: filetype=sshconfig:

Host github.com
    User git
    IdentityFile ~/.ssh/github/kapsh_github

When all hosts (except default options for Host *) are configured in this way, sshto just shows nothing and exits.

Dialog error message is `Expected at least 20 tokens` since Awk changes

Dialog doesn't like the new awk list creation (commit 68ad4dd). Specialy this line create problem:
--menu "Select host to connect to. $USERNOTE" 0 0 0 "${list[@]}")

Dialog error message is
Expected at least 20 tokens for --men, have 4.
followed by
ESC[0mESC[?25hESC[HESC[2JESC[3J
followed by current directory content.

Unrelated, but additonaly only few lines of the output can be seen, and the output is not browsable (terminal window looks locked at current screen).

It is a known issue with Dialog, very similar to this old error on slackware. Browse at the bottom for explanation.

Failed run permission problem ?

awk: cmd. line:14: fatal: cannot open file '/home/username/.ssh/config*[!~]' for reading: no such file of directory

Permission on config

stat -c "%a %n" /home/username/.ssh/config
644 /home/username/.ssh/config

username@debian:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye

Failed run on ubuntu 20

Hello, failed run on ubuntu

softj@softjpc:~$ lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.4 LTS
Release:	20.04
Codename:	focal
softj@softjpc:~$ uname -r
5.13.0-39-generic

I get this error

awk line 17 function gensub never defined

after install gawk it was fixed for me

sudo apt install gawk

may be should add this to readme or checking in sshto script?

Menu Separators No Longer Working

I just reloaded one of my machines and did a fresh clone of the repo. Using the same config file as before, the updated version of the script no longer seems to honor the #Host DUMMY #SiteName# moniker anymore, it just shows all hosts in a single, large list.

Add support for zsh

As title says - add zsh support. Otherwise I cannot run the project on my Apple Air M2.
One more thing - if I try to run it trough bash I got (on latest OS with all updates passed and brew upgrade as well):

BASH version 4.2+ required to run sshto, your is - 3.2.57(1)-release

Thanks.

Name or service not knownname <hostname>

my ~/.ssh/config looks like this:

Host *
ForwardAgent yes
ServerAliveInterval 120
IdentityFile /path/to/default/default/ssh/key
...
Host gate
User tim
Hostname 1.2.3.4
Port 22
LocalForward 1234 192.168.1.1:1234

after running sshto and selecting host gate I got error: Name or service not knownname gate

my default shell is zsh. But I run /bin/bash before starting sshto. I use Linux Mint 21.2

Declare -A invalid option

There's some issue with declare option -A

Device: MacBook M1
Os: 12.3

Screen.Recording.2022-10-17.at.10.32.38.AM.mov

Screenshot 2022-10-17 at 10 38 40 AM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.