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
env.use_ssh_config = True env.host_string ='Target host' env.user ='username' env.password ='password name'
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