Coder Social home page Coder Social logo

ssh_manager's Introduction

ssh_manager

- Keep all ssh connection next to you

And don't distract on password prompts

ssh_manager: 

usage: ssh_m [-h] [-n] [-R] [-C]

optional arguments:
  -h, --help  show this help message and exit
  -n          Proceed new SSH connection to storage Executed by default if storage is empty.
  -R          Acts same as $SSH_M_R Prevents renaming TMUX window on SSH connection.
  -C          Acts same as $SSH_M_C Prevents closing of TMUX after SSH is disconnected.

Deploying

Normally it works only on UNIX-like systems due to envvars, sshpass and simple-term-menu OS support, but everything is possible...

1. Environment

  • sshpass - Non-interactive ssh password authentication

  • Python 3 > 3.10

  • $servernickname_user - Environment variable stores the password

    • Can be installed to .zshrc / .bashrc from special branch

Install dependencies

sudo apt install sshpass

  • sshpass -V (Verify sshpass installation)

sudo apt install python3.10

  • python3.10 -V (Verify python installation)

git clone -b shellscript https://github.com/LoliPain/ssh_manager

cd ssh_manager

python3 main.py

  • Follow the steps in script

    • Reload shell (source ~/.bashrc / source ~/.zshrc)

Now you can export passwords from specified folder using in your shell:

servernickname username

> Exported username@servernickname password

2. Installation

  • Clone the repo
git clone https://github.com/LoliPain/ssh_manager
  • Install it system-wide
cd ssh_manager

python3 -m pip install .

  • Remove the sources
cd ..

rm -rf ssh_manager

3. Usage

  • Remote selection:
@ ssh_m

 -----

ssh_manager: 

> [email protected]
  [email protected]
  • Add new remote
@ ssh_m -n

 -----

ssh_manager: 

Hostname (eg. google.com): simplifymilk.local
Remote user: test
Name of remote using for stored password (and env variable): simmilk

 -----

> [email protected]
  [email protected]
  [email protected]

Configuration

As mentioned before ssh_manager aims to rename TMUX active window and close pane at session disconnect. There's a few options how to configure that behavior:

Launch arguments

@ ssh_m -R - [R]ename - will prevent ssh_manager renaming active TMUX window

  • Is alternative to $SSH_M_R environment variable. Could be any value except empty

@ ssh_m -C - [C]lose - will prevent ssh_manager closing pane after SSH terminated

  • Is alternative to $SSH_M_C environment variable. Could be any value except empty

Important notes

  • Keep in mind that environment variable $servernickname_user is REQUIRED

  • ssh_manager by default is checking whether running inside TMUX, and applies those actions to it

    • Renaming current window to active ssh session
    • Termination shell on ssh disconnect

ssh_manager's People

Contributors

lolipain avatar

Watchers

 avatar

ssh_manager's Issues

Try to execute command generated by shellscript

Describe your suggestion here

You can also attach some code snippets or screenshots


Run 'hostname' 'username' command generated by shellscript before attempting to execute sshpass -p
Alternatively possible to create a specified envvar using stored data without plain executing command

Why do you think that is a good update?

  • Will be useful for those who forget to execute it by themselfs

Shellscript won't work with supported shell

Definitely a ssh_manager issue

There's a non-zero chance of your issue to pend isn't really related to ssh_manager, so please make sure that:

  1. Re-read the README installation and configuration guide and follow all of those steps
  2. Verify that $servername_user environment that should contain the password for the remote machine exists in your current shell session:
    @ echo $servername_user
    (Where servername and user are matching the entry in ssh_manager storage)
  3. Verify sshpass -p direct connection to remote:
    @ sshpass -p $servername_user ssh user@remoteip
    NOTE that user in $servername_user should be exactly the same as user in ssh user@remoteip
  4. Verify python installation itself:
    @ python3 -V
    OR
    @ python3.x -V where's x is your python release

Checklist:

  • My issue is not related to connection problems or I'm aware that my ssh_manager storage and shell environment is fine
    • Direct connection using sshpass -p is performed, but connection through ssh_manager seems inappropriate
  • Broken functionality is declared and documented in the README project description

A detailed explanation of the issue goes here

Screenshots, screencasts, and other useful information are welcome


Some shell are manages to bind itself inside /usr/local/bin/ instead /usr/bin/
So preventing usage of shellscript even with supported shells due to
https://github.com/LoliPain/ssh_manager/blob/92fd48c65939cf1dcb57578ea778ca5c47d9b1d3/main.py#L23C1-L33

Proper solution will be extend those case clause with /usr/local/bin prefixes

Interactive remove existing connection from storage

Describe your suggestion here

You can also attach some code snippets or screenshots


Add launch parameter for interactive removing of existing connection via tui menu

Why do you think that is a good update?

  • Interactive removing always more convenient
  • For now it's inconsistent storage location and depended by installation method
    ...

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.