FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ssh-python/examples/exec.py at master · ParallelSSH/ssh-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ParallelSSH
/
ssh-python
Public
Notifications
You must be signed in to change notification settings
Fork
29
Star
48
Code
Issues
1
Pull requests
1
Discussions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Security and quality
Insights
Expand file tree
Breadcrumbs
ssh-python
/
examples
/
exec.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (27 loc) · 643 Bytes
Breadcrumbs
ssh-python
/
examples
/
exec.py
Copy path
File metadata and controls
33 lines (27 loc) · 643 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
27
28
29
30
31
32
33
import
os
import
pwd
import
socket
from
ssh
.
session
import
Session
from
ssh
import
options
# Linux only
USERNAME
=
pwd
.
getpwuid
(
os
.
geteuid
()).
pw_name
HOST
=
'localhost'
PORT
=
22
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
connect
((
HOST
,
PORT
))
s
=
Session
()
s
.
options_set
(
options
.
HOST
,
HOST
)
s
.
options_set
(
options
.
USER
,
USERNAME
)
s
.
options_set_port
(
PORT
)
s
.
set_socket
(
sock
)
s
.
connect
()
# Authenticate with agent
s
.
userauth_agent
(
USERNAME
)
chan
=
s
.
channel_new
()
chan
.
open_session
()
chan
.
request_exec
(
'echo me'
)
size
,
data
=
chan
.
read
()
while
size
>
0
:
print
(
data
.
strip
())
size
,
data
=
chan
.
read
()
chan
.
close
()
Back
|
FazBrowse Home
|
New Git URL