安裝zssh
brew install zssh
原文:用python指令碼傳 原文:
#!/usr/bin/env python
# coding=utf-8
from optparse import optionparser
import paramiko
import os,sys,time
"""這個指令碼的作用是實現堡壘機模式下,檔案上傳
"""parser = optionparser()
parser.add_option('-j', '--jumperuser', dest='jumperuser', help='company jumper machine account like wutengfei, ..')
parser.add_option('-u', '--username', dest='username', help='target machine account like wutengfei, ..')
parser.add_option('-p', '--port', dest='port', help='target machine port')
parser.add_option('-m', '--hostname', dest='hostname', help='target machine ip address like 192.168.246.168')
parser.add_option('-l', '--localpath', dest='localpath', help="client local file path like '/users/test.py'")
parser.add_option('-d', '--destpath', dest='destpath', help="jumper server file path like '/tmp/test.py'")
parser.add_option('-t', '--targetpath', dest='targetpath', help="remote server file path like '/tmp/test.py'")
(opts,args) = parser.parse_args()
#定義跳板機資訊
jumpername = "jumper.shuju.com" # 跳板機ip/網域名稱
jumperport = 22 # 跳板機ssh埠
paramiko.util.log_to_file('syslogin.log')
class jumperinfo(object):
"""將檔案從客戶端上傳至跳板機
"""def __init__(self,username,localpath,destpath):
self.username = str(username)
self.localpath = str(localpath)
self.destpath = str(destpath)
def jumper_ftp(self,jumperuser,localpath,destpath):
private_key = os.path.expandvars('$home/.ssh/id_rsa')
private_key = paramiko.rsakey.from_private_key_file(private_key)
t = paramiko.transport(('jumper.shuju.com', 22))
t.connect(username=jumperuser, pkey=private_key)
sftp = paramiko.sftpclient.from_transport(t)
sftp.put(localpath,destpath)
sftp.close()
passinfo='\'s password: '
class jumper_put(jumperinfo):
"""將跳板機上的檔案上傳至目標機
"""def __init__(self,hostname,username,port,targetpath):
self.hostname = str(hostname)
self.username = str(username)
self.port = str(port)
self.targetpath = str(targetpath)
def jumper_scp(self,jumperuser,destpath,username,hostname,targetpath,port):
ssh = paramiko.sshclient()
ssh.set_missing_host_key_policy(paramiko.autoaddpolicy())
privatekey = os.path.expandvars('$home/.ssh/id_rsa')
key = paramiko.rsakey.from_private_key_file(privatekey)
ssh.connect(hostname='jumper.shuju.com', username=jumperuser, port=22, pkey=key)
channel = ssh.invoke_shell()
channel.settimeout(10)
buff = ''
resp = ''
channel.send('scp ' + ' ' + '-p' + ' ' + port + ' ' + destpath + ' ' + username + '@' + hostname + ':' + targetpath + '\n')
while not buff.endswith('$ '):
resp = channel.recv(9999)
if not resp.find(passinfo)==-1:
print 'error info: authentication failed.'
channel.close()
ssh.close()
sys.exit()
buff += resp
print buff
channel.close()
ssh.close()
def main():
jumper_ssh = jumperinfo(username=opts.jumperuser,localpath=opts.localpath,destpath=opts.destpath)
jumper_ssh.jumper_ftp(opts.jumperuser,opts.localpath,opts.destpath)
target_ssh = jumper_put(hostname=opts.hostname,username=opts.username,port=opts.port,targetpath=opts.targetpath)
target_ssh.jumper_scp(opts.jumperuser,opts.destpath,opts.username,opts.hostname,opts.targetpath,opts.port)
if __name__ == '__main__':
if opts.jumperuser == none or opts.username == none or opts.hostname == none or opts.localpath == none or opts.destpath == none or opts.targetpath == none or opts.port == none:
parser.print_help()
exit(-1)
main()
mac配置ansible透過堡壘機操作
一 安裝 brew install ansible sudo pip install ansible 二 配置免密登陸 網上有很多 三 建立目錄和檔案 mac中 etc ansible 這個目錄下是沒有任何檔案的,裡面需要的任何檔案都需要自己去建立 etc ansible 這個目錄,ansible目...
堡壘機技術
有一句名言 堡壘往往從內部攻破。在資訊化社會,資訊保安發展的程序,已經清晰地印證了這個道理。如何加固組織機構內部網路的 內防體系 有效防範打擊 內鬼 杜絕因為內部隱患而導致的資訊遭竊密 資料被篡改 系統被破壞等嚴重後果,成為近年內國際資訊保安業界在內網安全領域的新課題。資料內控,也自然成為整個行業市...
天融信堡壘機
恢復出廠設定後的網口配置 使用console口登入root,密碼 njhsecxinan 2016 2 或 jhsec iam2015 編輯 vim etc network inte ce 將以下內容貼到裡面 auto lo iface lo inet loopback allow hotplug ...