FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learn-python/python_tips/python_remote_ssh_fabric.py at main · miltozz/learn-python · GitHub
miltozz
/
learn-python
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
learn-python
/
python_tips
/
python_remote_ssh_fabric.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 849 Bytes
Breadcrumbs
learn-python
/
python_tips
/
python_remote_ssh_fabric.py
Copy path
File metadata and controls
26 lines (21 loc) · 849 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from
fabric
import
Connection
from
invoke
import
Responder
# fabric creates a copy of known_hosts and automatically adds new hosts to it.
# it doesn't change the original ./ssh/known_hosts
# set host 'ec2-monitor' in .ssh/config to be read automatically
# else must specify connection details here
result
=
Connection
(
'ec2-monitor'
).
run
(
'docker ps'
,
hide
=
True
)
msg
=
"Ran {0.command!r} on {0.connection.host}, got stdout:
\n
{0.stdout}"
print
(
msg
.
format
(
result
))
""" # other syntax
c = Connection('ec2-monitor')
r = c.run('sudo whoami', hide=True)
msg = "Ran {0.command!r} on {0.connection.host}, got stdout:
\n
{0.stdout}"
print(msg.format(result)) """
# sudo password prompt
""" c = Connection('host')
sudopass = Responder(
pattern=r'\[sudo\] password:',
response='mypassword
\n
',
)
c.run('sudo whoami', pty=True, watchers=[sudopass]) """
Back
|
FazBrowse Home
|
New Git URL