Use fabric as is in python (fabric3)

I found it easy to use fabric from within a normal script, so I will write it as a memo.

From jupyter, it may be quite convenient to use

from fabric.api import env,sudo,get,run,put,local,execute,hosts from fabric.decorators import task,hosts from fabric.context_managers import hide

And specify

ssh_config, if any

env.use_ssh_config = True env.host_string ='Target host' env.user ='username' env.password ='password name'

When specifying keyfile

Specify as env.key_filename ='/Users/hoge/.ssh/id'. It can also be used on windows. It seems that it should be #key_filename. In ubuntu, it seems that env.keyfile can also be used.

After that, x = run('ls -l /srv/www')

And so on. I haven't confirmed get, put, etc. yet, but it will probably work.

Recommended Posts

Use fabric as is in python (fabric3)
How to use is and == in Python
Use config.ini in Python
Use Valgrind in Python
Use profiler in Python
Use python in Docker container as Pycharm interpreter
Let's use def in python
Use let expression in Python
Use Measurement Protocol in Python
Use callback function in Python
Use parameter store in Python
Python is painful. But use
Use HTTP cache in Python
Use MongoDB ODM in Python
Use list-keyed dict in Python
Use Random Forest in Python
Use regular expressions in Python
Use Spyder in Python IDE
Use pymol as a python library
Difference between == and is in python
Python is UnicodeEncodeError in CodeBox docker
How to use SQLite in Python
Use rospy with virtualenv in Python3
Grayscale image is displayed as a color image in OpenCV / Python
Use blender as a python module
How to use Mysql in python
Use Python in pyenv with NeoVim
There is no switch in python
How to use ChemSpider in Python
Use embeddable Python as Vim's Python 3 interface
How to use PubChem in Python
Use OpenCV with Python 3 in Window
Python in is also an operator
python: Use the variables defined in the string format as they are
How to use the asterisk (*) in Python. Maybe this is all? ..
[Introduction to Python] How to use class in Python?
Use print in a Python2 lambda expression
"<" In python> pack ("<L", ...) is little endian
Inject is recommended for DDD in Python
Easily use your own functions in Python
Easy way to use Wikipedia in Python
What is "mahjong" in the Python library? ??
Hash in Perl is a dictionary in Python
Don't use \ d in Python 3 regular expressions!
[Python] Complete preprocessing Memo as it is
How to use __slots__ in Python class
Use pathlib in Maya (Python 2.7) for upcoming Python 3.7
How to use regular expressions in Python
Quadtree in Python --2
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Python is easy
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python