Coder Social home page Coder Social logo

parallel-ssh's Introduction

原版的pssh,只在使用无密码证书登陆的时候非常方便,而对只支持密码登陆的ssh主机,则会弹出输入密码的交互提示,导致自动化脚本运行不自动了.

由于服务器比较多,并且登陆方式不一样,有的用证书,有的使用密码,所以对pssh作一点hack,以方便提高工作效率.

现在对pssh稍微做了点修改,在定义hosts.txt文件的时候,可选地加入密码项,如果检测到密码则使用sshpass这个命令来处理密码的自动输入功能.这样就能全自动进行了.

原来的hosts.txt 格式:
 1. host[:port] [login]
 2. [user@]host[:port]

hack后的文件格式:
 1. host[:port] [login[:passwd]]
 2. [user[:passwd]@]host[:port]

虽然这样有些安全问题,但即使使用证书也存在同样级别的安全问题,因为如果保存hosts.txt的主机不安装,那么这主机上的登陆证书一样不安全. 把hosts.txt的权限设置与证书权限一样高,安全性是一样的.


依赖外部包:
    sshpass

修改的源文件:
    psshlib/psshutil.py
    bin/pssh
    bin/pscp
    bin/pnuke
    bin/prsync
    bin/pslurp

parallel-ssh's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

parallel-ssh's Issues

希望能内置expect功能~

当本机第一次pssh远程主机时会失败,因为第一次ssh会出现如下选择:

Are you sure you want to continue connecting (yes/no)? yes

shell下可以用expect来处理,而python下有pexpect,希望pssh能内置此功能~

prsyc error when using -O option

it shows
UnboundLocalError: local variable 'ssh' referenced before assignment

i check the source code and the reson is you commented ssh = ['ssh'] in line 72, and when passwd == None,this variable will not be assigned. then it died when i use -O option.

    # ssh = ['ssh']
    if passwd == None:
        ssh = ['ssh']
        # sys.stderr.write('using standard ssh method\n')
    else:
        cmd = ['sshpass', '-p', passwd, 'ssh']
        # sys.stderr.write('using sshpass method\n')

    if opts.options:
        for opt in opts.options:
            ssh += ['-o', opt]
    if port:
        ssh += ['-p', port]
    if opts.ssh_args:
        ssh += [opts.ssh_args]

    cmd = ['rsync', '-e', ' '.join(ssh)]

i modified code like below, problem resolved.
ssh = ['ssh']

    if opts.options:
        for opt in opts.options:
            ssh += ['-o', opt]
    if port:
        ssh += ['-p', port]
    if opts.ssh_args:
        ssh += [opts.ssh_args]

    if passwd == None:
        cmd = ['rsync', '-e', ' '.join(ssh)]
        # sys.stderr.write('using standard ssh method\n')
    else:
        cmd = ['sshpass', '-p', passwd, 'rsync', '-e', ' '.join(ssh)]
        # sys.stderr.write('using sshpass method\n')

pssh --help的主机相关提示还是旧的~

 pssh --help
Usage: pssh [OPTIONS] -h hosts.txt command [...]

Options:
  --version             show program's version number and exit
  --help                show this help message and exit
  -h HOST_FILE, --hosts=HOST_FILE
                        hosts file (each line "[user@]host[:port]")
  -H HOST_STRING, --host=HOST_STRING
                        additional host entries ("[user@]host[:port]")

主机格式还是旧的,应该是:

    1. host[:port] [login[:passwd]]
    2. [user[:passwd]@]host[:port]

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.