• gossh工具


    gossh
    #单机模式
    1.远程运行命令
    gossh [-t cmd] -h hostname -P port(default 22) -u username(default root) -p passswrod  [-f]  "command"
    gossh -h 192.168.15.6 -t cmd -u root -p 123456 -P 22 "uname"
    gossh -h 192.168.15.6 -t cmd -u root -p 123456 -P 22 "cd /tmp/test&&touch test.sh"
    使用-f强制执行命令,一些危险命令拒绝执行,使用-f强制执行
    gossh -h 192.168.56.2 -f "cd /tmp && rm ip.txt"
    2.推送文件到远程主机
    支持推送文件或者文件夹到远程主机,如果远程主机已经存在文件,默认是拒绝执行,可以使用-f参数强制覆盖
    gossh -t push -h hostname -P port(default 22) -u username(default root) -p passswrod [-f] localfile/localpath remotepath
    gossh -h 192.168.15.6 -t push -u root -p 123456 -P 22 ip.txt /tmp/test
    gossh -h 192.168.15.6 -t push -u root -p 123456 -P 22 log /tmp/test
    3.从远程主机拉取文件
    gossh -t pull -h hostname -P port(default 22) -u username(default root) -p passswrod remote_file local_path
    注意:如果local_path不存在,会自动创建。
    gossh -h 192.168.15.6 -t pull -u root -p 123456 -P 22 /tmp/test/ip.txt .
    
    #批量模式
    批量模式和单机模式的区别:
    使用-i参数代替-h指定批量运行的ip文件。
    可以是用-c参数指定并发度。
    如果密码加密了,需要带上-e参数告诉gossh密码已经加密。
    批量拉取文件到本地时,由于是文件都一样,文件会放到local_path/ip下,
    单机模式时直接放在local_path指定本地目录,但是批量模式,放到local_path下每个主机ip子目录下。
    1.批量远程运行命令
    gossh -t cmd -i ip.txt "command"
    2.推送文件到批量远程主机
    gossh -t push -f -i ip.txt test.txt /tmp/test
    3.批量从远程主机拉取文件到本地
    gossh -t pull -f -i ip.txt /tmp/testtest.txt /tmp
    
    #使用说明
    gossh可以完成简单的命令执行,文件传递等工作,也可以完成复查的工作。
    完成复杂工作需要在本地编写脚本,推送脚本文件,然后远程执行脚本,再将脚本执行结果文件拉取到本地分析处理。
    
    #参考链接
    https://github.com/andesli/gossh
    
  • 相关阅读:
    Sort函数的用法
    hdu 1087 Super Jumping! Jumping! Jumping!(最大上升子序列和)
    hdu 1159 Common Subsequence(LCS)
    最长公共子序列
    蓝桥杯 -- 取字母
    蓝桥杯 -- 串的处理
    蓝桥杯 -- 奇怪的比赛
    蓝桥杯 -- 微生物繁殖
    hdu 1159 Common Subsequence(最长公共子序列)
    hdu 2458 Kindergarten
  • 原文地址:https://www.cnblogs.com/kylingx/p/13267611.html
Copyright © 2020-2023  润新知