Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
62fb32d8
Commit
62fb32d8
authored
Jan 20, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature] support session clone
parent
d85e4055
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
sshd.py
coco/sshd.py
+18
-10
No files found.
coco/sshd.py
View file @
62fb32d8
...
@@ -9,6 +9,8 @@ import threading
...
@@ -9,6 +9,8 @@ import threading
import
paramiko
import
paramiko
import
sys
import
sys
import
time
from
.utils
import
ssh_key_gen
from
.utils
import
ssh_key_gen
from
.interface
import
SSHInterface
from
.interface
import
SSHInterface
from
.interactive
import
InteractiveServer
from
.interactive
import
InteractiveServer
...
@@ -48,13 +50,13 @@ class SSHServer:
...
@@ -48,13 +50,13 @@ class SSHServer:
try
:
try
:
sock
,
addr
=
self
.
sock
.
accept
()
sock
,
addr
=
self
.
sock
.
accept
()
logger
.
info
(
"Get ssh request from {}: {}"
.
format
(
addr
[
0
],
addr
[
1
]))
logger
.
info
(
"Get ssh request from {}: {}"
.
format
(
addr
[
0
],
addr
[
1
]))
thread
=
threading
.
Thread
(
target
=
self
.
handle
,
args
=
(
sock
,
addr
))
thread
=
threading
.
Thread
(
target
=
self
.
handle
_connection
,
args
=
(
sock
,
addr
))
thread
.
daemon
=
True
thread
.
daemon
=
True
thread
.
start
()
thread
.
start
()
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Start SSH server error: {}"
.
format
(
e
))
logger
.
error
(
"Start SSH server error: {}"
.
format
(
e
))
def
handle
(
self
,
sock
,
addr
):
def
handle
_connection
(
self
,
sock
,
addr
):
transport
=
paramiko
.
Transport
(
sock
,
gss_kex
=
False
)
transport
=
paramiko
.
Transport
(
sock
,
gss_kex
=
False
)
try
:
try
:
transport
.
load_server_moduli
()
transport
.
load_server_moduli
()
...
@@ -73,17 +75,23 @@ class SSHServer:
...
@@ -73,17 +75,23 @@ class SSHServer:
logger
.
warning
(
"Handle EOF Error"
)
logger
.
warning
(
"Handle EOF Error"
)
return
return
chan
=
transport
.
accept
(
10
)
while
True
:
if
chan
is
None
:
chan
=
transport
.
accept
()
logger
.
warning
(
"No ssh channel get"
)
if
chan
is
None
:
return
continue
server
.
event
.
wait
(
5
)
if
not
server
.
event
.
is_set
():
logger
.
warning
(
"Client not request a valid request, exiting"
)
return
server
.
event
.
wait
(
5
)
t
=
threading
.
Thread
(
target
=
self
.
handle_chan
,
args
=
(
chan
,
request
))
if
not
server
.
event
.
is_set
():
t
.
daemon
=
True
logger
.
warning
(
"Client not request a valid request, exiting"
)
t
.
start
()
return
def
handle_chan
(
self
,
chan
,
request
):
client
=
Client
(
chan
,
request
)
client
=
Client
(
chan
,
request
)
print
(
chan
)
print
(
request
)
self
.
app
.
add_client
(
client
)
self
.
app
.
add_client
(
client
)
self
.
dispatch
(
client
)
self
.
dispatch
(
client
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment