Mac terminal SSH client shuttle password free

Source: Internet
Author: User
Tags python script

Enter password-free login

No need for third-party software such as Iterm and Zoc, alias (pure terminal) and shuttle (with UI) to log on to the target machine using the password (no manual input required)

Preparation Tools

Sshpass,shuttle

Password configuration file

Password file (clear text storage, if you consider strong security issues, please bypass)
Format: hostname (defined in system Hosts file), user, password, ssh_port

$ cat /Users/zhang/zhangsan/work/secure vm-001 root 123456 1122vm-002 root 123456 22
Script
    1. Core scripts
$ cat /Users/zhang/zhangsan/work/ssh.sh #!/bin/shWORK_DIR=$(dirname $0)cd $WORK_DIRHOST=$1;USER=$2;if [ "x${HOST}" == "x" -o "x${USER}" == "x" ]; then    exit 2fiPASS_PORT=$(grep -E "^$HOST\s+$USER\s+" secure)PASS=$(echo $PASS_PORT | awk ‘{print $3}‘)PORT=$(echo $PASS_PORT | awk ‘{print $4}‘)if [ "x${PASS}" == "x" -o "x${PORT}" == "x" ]; then    exit 2fiexec sshpass -p $PASS ssh -p $PORT [email protected]$HOST

The update logic script is stored to ~/.bash_profile, and each login will regenerate the required configuration files for alias and shuttle based on secure

    1. Alias
      After you add the following script in ~/.bash_profile, update the alias

      while read LINEdoSSH_HOST=$(echo "$LINE" | awk ‘{print $1}‘)SSH_USER=$(echo "$LINE" | awk ‘{print $2}‘)alias "$SSH_HOST$SSH_USER"="sh /Users/zhang/zhangsan/work/ssh.sh $SSH_HOST $SSH_USER"done < /Users/zhang/zhangsan/work/secure
    2. Shuttle
      Generate a Python script for shuttle configuration
$ cat /Users/zhang/zhangsan/work/shuttle.py import jsonshuttle = {  "editor": "default",  "launch_at_login": True,  "terminal": "Terminal.app",  "iTerm_version": "nightly",  "default_theme": "Default",  "open_in": "tab",    "show_ssh_config_hosts": False,  "ssh_config_ignore_hosts": [],  "ssh_config_ignore_keywords": [],  "hosts": []}with open("/Users/zhang/zhangsan/work/secure", "r") as f:    while True:        line = f.readline()        if not line:            break        HOST_PORT = line.split()        if len(HOST_PORT) >= 3:            HOST, PORT = HOST_PORT[0], HOST_PORT[1]            shuttle["hosts"].append({"cmd": "sh /Users/zhang/zhangsan/work/ssh.sh {HOST} {PORT}".format(HOST=HOST, PORT=PORT) , "name": "{HOST} {PORT}".format(HOST=HOST, PORT=PORT)})with open("/Users/zhang/.shuttle.json", "w") as f:    json.dump(shuttle, f, indent=2)

Add python/users/zhang/zhangsan/work/shuttle.py to ~/.bash_profile, generate shuttle configuration file

Note

Mac Zoc is a simple and easy to use an SSH client, but has crashed several times (genuine will be better)

Reference links

Download Shuttle
Installing Sshpass

Mac terminal SSH client shuttle password free

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.