Python3 FABRIC3 Module Implementation key Login
Go online search, found a pile of articles, such as the official website execution documentation, official website SSH use documentation, as well as official website password-management use documentation.
And all I want is to know how to use a key to link to a remote host. Easy, just look below.
Configure a fabfile.py file.
From FABRIC.API import *
env.hosts = [' 192.168.181.200 '] # Specify hosts remote host
env.key_filename = '/path/to/id_ RSA ' # Specifies your private key file
Env.user = ' username ' # Specify user name
def touchfile (): # Create a random task to test
run (' Touch/ Tmp/www.txt ')
In writing Env.key_filename, in the Pycharm tool inside, and there is no automatic completion key_filename, not to say wrong or not, write directly on the can. As for why does not have the automatic completion, temporarily did not find the reason.
Executing commands on the command line
Fab touchfile
Output results:
[192.168.181.200] Executing task ' lspath '
[192.168.181.200] run:touch/tmp/www.txt done
.
Disconnecting from 192.168.181.200 ... Done.