我有一个nat,它有各种服务器 所以我想从本地服务器转到nat,然后从nat到其他计算机ssh
I have a nat and it has various server So from my local server I want to go to nat and then from nat i have to ssh to other machines
本地-> NAT(密钥1的abcuser @ publicIP)->服务器1(密钥2的xyzuser @ localIP) nat有不同的ssh键 并且每个服务器都有不同的ssh密钥 我如何使用Fabric完成这种类型的多跳SSH 我尝试使用 env.roledefs 功能,但似乎不起作用 我也不确定如何定义两个ssh密钥.我知道我们可以定义一个带有env.key_filename的密钥列表,但是问题是它将检查每个服务器的每个密钥吗?如何更具体地将一个密钥与一个服务器匹配仅
Local-->NAT(abcuser@publicIP with key 1)-->server1(xyzuser@localIP with key 2) nat has different ssh key and each of the server has different ssh key how can i accomplish this type of multihop ssh using fabric I tried using env.roledefs feature but it doesnt seems to be working also I am not sure how to define two ssh keys.I know we can define a list of keys with env.key_filename but issue is will it check each key with each server?How can I be more specific and match a key with one server only
我尝试使用本地计算机上的命令 工厂部署-g'ec2-user@54.251.151.39'-i'/home/aman/Downloads/aws_oms.pem' 而我的脚本是
I have tried using command from my local machine fab deploy -g 'ec2-user@54.251.151.39' -i '/home/aman/Downloads/aws_oms.pem' and my script is
from __future__ import with_statement from fabric.api import local, run, cd, env, execute env.hosts=['ubuntu@10.0.0.77'] env.key_filename=['/home/ec2-user/varnish_cache.pem'] def deploy(): run("uname -a")推荐答案
要通过中间服务器连接到远程主机,可以使用--gateway命令行选项:
In order to connect to remote hosts via an intermediate server, you can use the --gateway command-line option :
docs.fabfile/en /latest/usage/fab.html#cmdoption-g
或者,或者,在fabfile中设置env.gateway变量:
Or, alternatively, set the env.gateway variable inside your fabfile :
docs.fabfile/en/latest /usage/env.html#gateway
有关更多详细信息,请参阅:
For more detail information, see:
docs.fabfile/en /stable/concepts/networking.html#ssh-gateways
更多推荐
如何用面料做多跳SSH
发布评论