This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
func ConnectSSH( host string, sshuser string, cmdbuser string ) { | |
config := &ssh.ClientConfig{ | |
User: "jenkins", | |
Auth: []ssh.AuthMethod{ | |
ssh.Password("654321"), | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 封装paramiko,实现文件发送 | |
def push_file(ip, local_file, remote_file, port=22, user="root", pkey="/root/.ssh/id_rsa"): | |
try: | |
p_key = paramiko.RSAKey.from_private_key_file(pkey) | |
scp = paramiko.Transport((ip, port)) | |
scp.connect(username=user, pkey=p_key) | |
sftp = paramiko.SFTPClient.from_transport(scp) | |
sftp.put(localpath=local_file, remotepath=remote_file) | |
scp.close() | |
result = {"status": True, "info": "Push file {0} to {1} succeed.".format(local_file, ip)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
import traceback | |
import os | |
import sys | |
try: | |
for env in TAIR_IP: | |
mykey = paramiko.RSAKey.from_private_key_file(os.path.expanduser('~/.ssh/id_rsa')) | |
t = paramiko.Transport((TAIR_IP[env][0], 22)) | |
t.connect(username='root', pkey=mykey) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
datetime.now().strftime("%Y%m%d-%H%M") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
#coding:utf-8 | |
# | |
import getopt,sys | |
def usage(): | |
""" | |
The output configuration file contents. | |