Code Monkey home page Code Monkey logo

slist's Introduction

slist

alt text

version CI

slist is a tool to list your servers in ssh config and ssh into it.
This only works on Unix machines.
slist aims to solve the problem of users having to remember aliases or IP addresses of all their servers.
slist reads the aliases in the ~/.ssh/config file and list them in the terminal.

Setting it up

$ cd <path_of_choice>
$ git clone https://github.com/GovTechSG/slist.git
$ chmod +x slist.sh

# Use full path of slist.sh for symlink to work
$ ln -s <path_of_choice>/slist.sh /usr/local/bin/slist
$ slist

SSH Config File Format

# If you have a jump host
Host jumpHost
  User <your_user>
  HostName <ip_address>
  Port 22
  IdentityFile <path_to_private_key>

Host <your_host>
  User <your_user>
  HostName <ip_address>
  ProxyCommand ssh -A jumpHost nc %h %p   # If you want to use the jumpHost to connect to the host
  Port 22
  IdentityFile <path_to_private_key>

Host <your_host2>
  User <your_user2>
  HostName <ip_address2>
  Port 22
  IdentityFile <path_to_private_key>

Usage

Usage: slist [-fhl] [--add-host host_name --ip-adr ip_address [--ssh-user user --port port_number --keypath keyname_with_path]] [--del-host host_name]

-f <keyword>                    Keyword to filter
-h                              Display help
-l                              List servers with ip addresses
-l -f <keyword>                 Filter list work <keyword>
-e                              Open and edit ~/.ssh/config
--add-host <host_name>          Add a new host to the SSH config file. Must be used together with --ip-adr option
--ip-adr <ip_address>           Add a new IP address to the SSH config file. Must be used together with --add-host option
--ssh-user <user>               Add a new SSH user to SSH config file. Must be used together with --add-host and --ip-adr options
--port <port_number>            Add a new port number to SSH config file. Must be used together with --add-host and --ip-adr options
--keypath <keyname_with_path>   Add a new key file to SSH config file. Must be used together with --add-host and --ip-adr options
--del-host <host_name>          Delete a host from the SSH config file
--file                   To use other config file
--init <file_path>              To initialize a template SSH config file

Changing colours theme for slist

To make persistent color change to slist theme.
If you are using bash shell, add below 2 lines to .bashrc or .profile or .bash_profile.
If you are using zsh shell, add below 2 lines to .zshrc.\

export color_theme1=cyan
export color_theme2=yellow

Supported colors: black red green yellow blue pink cyan white

Screenshots

Optional Text Optional Text

Developer Guide

Running Tests

To run tests in tests/slist_test.sh you will need to install shunit2

# To install shunit2 on MacOS
$ brew install shunit2

# To install shunit2 on Fedora/RHEL/CentOS/EPEL
$ yum install shunit2

# To install shunit2 on Ubuntu
$ apt-get install shunit2

# To run tests
$ ./tests/slist_test.sh

Contributing Your Code

If you would like to contribute to this repo, please open an issue, fork the repo, implement your code and tests and create a PR

License

This project is licensed under the MIT License - see the LICENSE file for details

slist's People

Contributors

alvinsiew avatar salihan04 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slist's Issues

Refactor slist

There are a couple of duplicate code and highly nested if-elif-else blocks

slist includes items in directory where `slist` is called

Installation steps taken:

git clone https://github.com/GovTechSG/slist.git
cd slist
chmod +x slist.sh
ln -s ${PWD}/slist.sh /usr/local/bin/slist

symlinks look fine:

$ ll /usr/local/bin/slist
lrwxr-xr-x  1 a662176  admin    29B Mar 18 17:17 /usr/local/bin/slist -> /Users/a662176/slist/slist.sh

Error Observed:

$ slist

image

Item 1. 2. 3. shouldnt be there

The items in the directory slist was called are also included in the list, any idea if its due to my set-up?

Here is the strucutre my config file for you ref:

Host *
  UseKeychain yes

Host alias1
   User ubuntu
   Hostname 1.1.1.1
   Port 22
   ForwardAgent yes


...

Host aliasn
   User ubuntu
   Hostname 1.1.1.1
   Port 22
   ForwardAgent yes

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.