Я пытался войти в маршрутизатор с сервера прыжков. Я попробовал этот код, но он дает ошибку, которую я не в состоянии понять. Пожалуйста, дайте мне знать, как решить эту ошибку или любые другие способы входа в маршрутизатор с сервера прыжков.
Пробный код:
from dotenv import load_dotenv
import jumpssh
import os
from jumpssh import SSHSession
load_dotenv()
jumpserver_ip = os.getenv("jumpserver_ip")
jumpserver_username = os.getenv("jumpserver_username")
jumpserver_password = os.getenv("jumpserver_password")
remote_ip = os.getenv("remote_ip")
remote_password = os.getenv("remote_password")
gateway_session = SSHSession(jumpserver_ip, jumpserver_username, password=jumpserver_password).open()
remote_session = gateway_session.get_remote_session(remote_ip, password=remote_password, allow_agent=False, look_for_keys=False)
fl = open('R1.txt', 'w')
fl.write(remote_session.get_cmd_output('show running config'))
fl.close()
remote_session.close()
gateway_session.close()
Ошибка:
Traceback (most recent call last):
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\jumpssh\session.py", line 160, in open
self.ssh_client.connect(**self.extra_parameters)
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\paramiko\client.py", line 446, in connect
passphrase,
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\paramiko\client.py", line 764, in _auth
raise saved_exception
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\paramiko\client.py", line 751, in _auth
self._transport.auth_password(username, password)
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\paramiko\transport.py", line 1509, in auth_password
return self.auth_handler.wait_for_response(my_event)
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\paramiko\auth_handler.py", line 250, in wait_for_response
raise e
paramiko.ssh_exception.AuthenticationException: Authentication failed.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "jump.py", line 17, in <module>
remote_session = gateway_session.get_remote_session(remote_ip, password=remote_password, allow_agent=False, look_for_keys=False)
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\jumpssh\session.py", line 514, in get_remote_session
retry_interval=retry_interval)
File "C:\python3\JUMPSE~1\jump\DOTENV~1\lib\site-packages\jumpssh\session.py", line 174, in open
% (self.host, self.port, self.username), original_exception=ex)
jumpssh.exception.ConnectionError: Unable to connect to '10.10.10.1:22' with user 'abc': Authentication failed.
Мой файл jump.env:
jumpserver_ip = 'your_jump_server_ip'
jumpserver_username = 'your_jump_server_username'
jumpserver_password = 'your_jump_server_password'
remote_ip = 'your_remote_node_ip'
remote_username = 'your_remote_node_username'
remote_password = 'your_remote_node_password'
Дайте мне знать, в чем проблема или любой другой способ входа.