mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-14 22:39:10 +00:00
catch excepition
This commit is contained in:
10
connect.py
10
connect.py
@@ -10,6 +10,7 @@ import sys
|
|||||||
import struct
|
import struct
|
||||||
import fcntl
|
import fcntl
|
||||||
import signal
|
import signal
|
||||||
|
import socket
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import termios
|
import termios
|
||||||
@@ -112,7 +113,16 @@ def connect(username, password, host, port):
|
|||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
ssh.load_system_host_keys()
|
ssh.load_system_host_keys()
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
try:
|
||||||
ssh.connect(host, port=port, username=username, password=password, compress=True)
|
ssh.connect(host, port=port, username=username, password=password, compress=True)
|
||||||
|
except paramiko.ssh_exception.AuthenticationException:
|
||||||
|
print 'Password Error, Please Correct it.'
|
||||||
|
time.sleep(2)
|
||||||
|
sys.exit()
|
||||||
|
except socket.error:
|
||||||
|
print 'Connect SSH Socket Port Error, Please Correct it.'
|
||||||
|
time.sleep(2)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# Make a channel and set windows size
|
# Make a channel and set windows size
|
||||||
global channel
|
global channel
|
||||||
|
Reference in New Issue
Block a user