[英]Python Fabric Laibrary ssh connection
I am unable to understand how should I set username, password, ip and port for my remote host in python fabric. 我无法理解如何在python结构中为远程主机设置用户名,密码,ip和端口。 I followed this .
我遵循了这一点 。 But the docs only explains like below:
但是文档仅解释如下:
from fabric.api import run
from fabric.api import env
env.hosts = [
'newyork',
'seattle',
'localhost',
]
def host_type():
run('uname -s')
def diskspace():
run('df')
I wonder how they are connecting to the hosts network etc without giving any connection or credential information? 我想知道他们如何在不提供任何连接或凭据信息的情况下连接到主机网络等?
Have you checked: http://docs.fabfile.org/en/1.10/usage/fab.html 您是否检查过: http : //docs.fabfile.org/en/1.10/usage/fab.html
You should use as a rule of thumb in SSH, SSH keys not password. 您应该在SSH中使用经验法则,SSH密钥而不是密码。
https://stackoverflow.com/a/5568219/1152669 https://stackoverflow.com/a/5568219/1152669
from fabric import env
env.hosts = ['user1@host1:port1', 'user2@host2.port2']
env.passwords = {'user1@host1:port1': 'password1', 'user2@host2.port2': 'password2'}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.