Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
9ba7ad14
Commit
9ba7ad14
authored
Dec 30, 2014
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改multi拼写错误
parent
b1e0a241
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
connect.py
connect.py
+8
-7
No files found.
connect.py
View file @
9ba7ad14
...
...
@@ -357,12 +357,12 @@ def connect(username, password, host, port, login_name, login_type='L'):
ssh
.
close
()
def
remote_exec_cmd
(
ip
,
port
,
username
,
passwd
,
cmd
):
def
remote_exec_cmd
(
ip
,
port
,
username
,
passw
or
d
,
cmd
):
try
:
time
.
sleep
(
3
)
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
connect
(
ip
,
port
,
username
,
passwd
,
timeout
=
5
)
ssh
.
connect
(
ip
,
port
,
username
,
passw
or
d
,
timeout
=
5
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
"bash -l -c '
%
s'"
%
cmd
)
out
=
stdout
.
readlines
()
err
=
stderr
.
readlines
()
...
...
@@ -377,18 +377,19 @@ def remote_exec_cmd(ip, port, username, passwd, cmd):
red_print
(
str
(
e
))
def
mu
tl
i_remote_exec_cmd
(
hosts
,
username
,
cmd
):
def
mu
lt
i_remote_exec_cmd
(
hosts
,
username
,
cmd
):
pool
=
Pool
(
processes
=
3
)
for
host
in
hosts
:
username
,
passw
d
,
ip
,
port
=
get_connect_item
(
username
,
host
)
pool
.
apply_async
(
remote_exec_cmd
,
(
ip
,
port
,
username
,
passwd
,
cmd
))
login_type
,
username
,
passwor
d
,
ip
,
port
=
get_connect_item
(
username
,
host
)
pool
.
apply_async
(
remote_exec_cmd
,
(
ip
,
port
,
username
,
passw
or
d
,
cmd
))
pool
.
close
()
pool
.
join
()
def
exec_cmd_servers
(
username
):
hosts
=
[]
green_print
(
"Input the Host IP(s),Separated by Commas, q/Q to Quit.
\n
You can choose in the following IP(s), Use Linux / Unix glob."
)
green_print
(
"Input the Host IP(s),Separated by Commas, q/Q to Quit.
\n
\
You can choose in the following IP(s), Use Linux / Unix glob."
)
print_user_host
(
LOGIN_NAME
)
while
True
:
inputs
=
raw_input
(
'
\033
[1;32mip(s)>:
\033
[0m'
)
...
...
@@ -416,7 +417,7 @@ def exec_cmd_servers(username):
f
=
open
(
filename
,
'a'
)
f
.
write
(
"DateTime:
%
s User:
%
s Host:
%
s Cmds:
%
s
\n
"
%
(
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
),
username
,
hosts
,
cmd
))
mu
tl
i_remote_exec_cmd
(
hosts
,
username
,
cmd
)
mu
lt
i_remote_exec_cmd
(
hosts
,
username
,
cmd
)
if
__name__
==
'__main__'
:
...
...
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