2 Star 7 Fork 2

code_son / ssh_skip_password

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

[ssh-skip-pwd]是ssh免密码工具。

    已测环境:
    os : Centos6.X
    编程语言: python2.6 + pip + pexpect + paramiko

    安装前置条件:
    1,确认python版本为2.6-2.x [非 python3]
    2,安装 pexpect 、paramiko组件
      建议:安装pip后使用pip 安装pexpect 、paramiko

    安装方法:
    a,复制ssh-skip-pwd文件到/usr/local/bin/中
    b,用户root用户为该脚本赋权限
      #chmod 755 /usr/local/bin/ssh-skip-pwd

    常见问题列表:
    问题1:
        Received disconnect from 172.17.0.229: 2: 
        Too many authentication failures lost connection

        解决办法: 编辑/etc/ssh/sshd_config,修改参数MaxAuthTries=2,把2调大一点10-20间即可


    参数列表简介:

    -f:host列表;指定一个文件全路径;无默认值。
    	文件内容示例
    	eg:
    	#ip	hostname
    	192.168.1.2		node1
    	192.168.1.3		node3

    -F: -F /path ,指定一个文件全路径;无默认值。该文件每一行包含:ip、hostname、password(远程服务器用户的密码)
    	文件内容示例
    	eg:
    	#ip		hostname		password
    	192.168.1.2		node1		123456
    	192.168.1.3		node3		3456787

    -h:帮助;

    -p:密码;

    -P:ssh port,ssh 的监听端口,默认值:22

    -s:服务器hostname或者IP;准备免密码连接其他服务器的机器名或者ip,默认值:localhost

    -u:用户名;非root用户做ssh免密码用

    -U:用户列表

    	文件内容示例
    	eg1:
    	#用户名
    	user1
    	user2
    	......

    	eg2:
    	#用户名		密码
    	user1		123456
    	user2		654321
    	......

    使用方法:

    场景一: 为当前登录用户在A服务器上做ssh免密码登录;
    	$(#) ssh-skip-pwd -p <password> -s <hostname/ip>

    场景二:A服务器当前登录用户u1,为自己在服务器B、C上做ssh免密码
    	$(#) ssh-skip-pwd -f <host列表文件全路径>  -p <password>
    	 -f参数文件内容:
    	第一列为IP,第二列为hostname
    	10.10.0.1		node01
    	10.10.0.2		node02

    	当用户u1在服务器B、C上密码不一至时
    	$(#) ssh-skip-pwd -F <host\pwd列表文件全路径>


    	 -F参数文件内容:

    	第一列为IP,第二列为hostname
    	10.10.0.1		node01		password1
    	10.10.0.2		node02		password2

    注意当u1为root时,-f -F 文件中的hosts信息会被更新到A服务器的hosts中,同时更新到服务器B、C上

    场景三:用户u1登录A服务器并为用户u2做ssh免密码登录服务器B、C
    要求:u2在ABCD服务器上的密码一致
    	$(#) ssh-skip-pwd -u u2 -p <u2 password>  -f <host列表文件全路径> (当u1用户为root时,需要加入该参数--curt_pwd=<root 的密码吗>)

    	 -f参数文件内容:
    	第一列为IP,第二列为hostname
    	10.10.0.1		node01
    	10.10.0.2		node02

    登录在A服务器上的用户u1为D服务器上用户u2做免密码登录服务器B、C

    	$(#) ssh-skip-pwd -u u2 -p <u2 password>  -f <host列表文件全路径> -s <服务器D的hostname> (当u1用户为root时,需要加入该参数--curt_pwd=<root 的密码吗>)

    	 -f参数文件内容:
    	第一列为IP,第二列为hostname
    	10.10.0.1		node01
    	10.10.0.2		node02

    注意当u1为root时,-f 文件中的hosts信息会被更新到A服务器的hosts中,同时更新到服务器B、C上

    场景四:A服务器上登录的用户u1为多个用户同时做ssh免密码登录服务器B、C
    要求:每个用户在ABCD服务器上密码一致
    	$(#) ssh-skip-pwd -U <user/pwd 列表文件> -f <host列表文件全路径> (当u1用户为root时,需要加入该参数--curt_pwd=<root 的密码吗>)
    	 -f参数的文件内容:

    	第一列为IP,第二列为hostname
    	10.10.0.1		node01
    	10.10.0.2		node02
    	 -U参数的文件内容:
    	第一列为用户名,第二列为密码
    	user1		password1
    	user2		password2
    	...

    登录在A服务器上的用户u1为D服务器上多个用户做免密码登录服务器B、C
    	$(#) ssh-skip-pwd -U <user/pwd 列表文件> -f <host列表文件全路径> -s <服务器D的hostname>  (当u1用户为root时,需要加入该参数--curt_pwd=<root 的密码吗>)

    注意当u1为root时,-f 文件中的hosts信息会被更新到A服务器的hosts中,同时更新到服务器B、C上
The MIT License (MIT) Copyright (c) 2016 code_son Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

[ssh-skip-pwd]是ssh免密码工具,使用python语言实现的工具; 主要功能: 本机用户ssh免密码到一台主机; 本机用户自己免密码到多台主机; 本机其他用户为某一用户做免密码到多台主机 本地用户对远程主机中用户免密码到多台主机 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/cson_765/ssh_skip_password.git
git@gitee.com:cson_765/ssh_skip_password.git
cson_765
ssh_skip_password
ssh_skip_password
master

搜索帮助

14c37bed 8189591 565d56ea 8189591