cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4665
Views
15
Helpful
8
Replies

Using jumpssh to ssh into a remote network devices over a windows jumpbox (Windows server 2012 R2 standard)

pn2020
Level 1
Level 1

Does anyone know if python jumpssh library works when the jumpbox is a windows? If you have a working implementation of jumpssh over a windows server jumpbox, I would love to hear your feedbacks and sharing. Do I have to install openssh on the windows jumpbox to make it work?  If you have suggestions for other solutions, I would love to hear.

 

From its documentation, it seems it would only work with a linux jumpbox.

 

https://pypi.org/project/jumpssh/

 

Thanks.

1 Accepted Solution

Accepted Solutions

Hi @pn2020 

I had a little play with jump_ssh .. thought might come handy at some point .. btw .. thanks for sharing :)

I used Windows 10 as jumpbox .. installed OpenSSH server - https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Simple to code I used to run show ver on remote host.

#!/usr/bin/env python

from jumpssh import SSHSession
from getpass import getpass

jumpbox = '172.16.100.13'
rhost = 'sbx-iosxr-mgmt.cisco.com'
juser = input("Jumpbox username: ")
jpass = getpass("Jumpbox password: ")

try:
    jump_session = SSHSession(jumpbox, username=juser, password=jpass).open()
    if jump_session.is_active() == True:
        print()
        print("Connected to jumpbox ... {}".format(jumpbox))
        try:
            remote_session = jump_session.get_remote_session(rhost, 
	                                                 username='admin', 
	                                                 port=8181, 
	                                                 password='C1sco12345', 
	                                                 look_for_keys=False,
	                                                 allow_agent=False,)
            if remote_session.is_active():
                print()
                print("Connected to remote host ... {}\n".format(rhost))
                result = remote_session.run_cmd('sh ver')
                print(result.output)
        except Exception as ex:
            print()
            print("Unable to connect to the remote host ... {}".format(rhost))
            print(ex)
            print()
        jump_session.close()
        print()
        print("Jumpbox connection closed.")
        print() 
except Exception as ex:
    print()
    print("Unable to connect to the jumpbox ... {}".format(jumpbox))
    print(ex)
    print()

jump.gif

View solution in original post

8 Replies 8

Manoj Papisetty
Cisco Employee
Cisco Employee

Which part of it is broken? SSH to the jump host itself or after that?

 

Are you able to SSH to the Windows jump host manually? (Like a putty or from terminal?)

Unfortunately, I can't.  I got @ssh_exchange_identification: read: Connection reset by peer, after being hung for a while.

 

Looking like, I have to talk to the server system admin to see if openssh can be installed on the windows jumpbox.

Actually, ssh from a local cmd widows to the windows jumpbox works.  But doesn't look like ssh is installed on the windows jumpbox, ie, ssh cli command isn't recognized.

Thanks everyone for your feedbacks.  I will look more into this.

Hi @pn2020 

I had a little play with jump_ssh .. thought might come handy at some point .. btw .. thanks for sharing :)

I used Windows 10 as jumpbox .. installed OpenSSH server - https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

Simple to code I used to run show ver on remote host.

#!/usr/bin/env python

from jumpssh import SSHSession
from getpass import getpass

jumpbox = '172.16.100.13'
rhost = 'sbx-iosxr-mgmt.cisco.com'
juser = input("Jumpbox username: ")
jpass = getpass("Jumpbox password: ")

try:
    jump_session = SSHSession(jumpbox, username=juser, password=jpass).open()
    if jump_session.is_active() == True:
        print()
        print("Connected to jumpbox ... {}".format(jumpbox))
        try:
            remote_session = jump_session.get_remote_session(rhost, 
	                                                 username='admin', 
	                                                 port=8181, 
	                                                 password='C1sco12345', 
	                                                 look_for_keys=False,
	                                                 allow_agent=False,)
            if remote_session.is_active():
                print()
                print("Connected to remote host ... {}\n".format(rhost))
                result = remote_session.run_cmd('sh ver')
                print(result.output)
        except Exception as ex:
            print()
            print("Unable to connect to the remote host ... {}".format(rhost))
            print(ex)
            print()
        jump_session.close()
        print()
        print("Jumpbox connection closed.")
        print() 
except Exception as ex:
    print()
    print("Unable to connect to the jumpbox ... {}".format(jumpbox))
    print(ex)
    print()

jump.gif

Wow, that's awesome, thanks omz for sharing!  I will play more with jumpssh.

jokey@telstra
Level 1
Level 1

@omz, thanks for sharing ! Solved my problem which uses RHEL linux distro as the jumphost.

 

I should add, in my case I needed to modify the jump.session sub-method port number from 8181 to 22.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: