Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to connect to device through proxy #47

Closed
vitodino opened this issue Apr 22, 2020 · 4 comments
Closed

Not able to connect to device through proxy #47

vitodino opened this issue Apr 22, 2020 · 4 comments

Comments

@vitodino
Copy link

vitodino commented Apr 22, 2020

I tried to connect to a router via a jumphost by following the guideline here:
https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/proxy.html

Here's my script:
from genie.testbed import load
from pyats.topology import loader

tb = load('testbed2.yaml')
pe1 = tb.devices['router1']
pe1.connect()
pe1.execute('show version')

Here's the testbed file:
testbed:
name: JUMPHOST_TESTBED
devices:
linux1:
os: linux
type: linux
credentials:
default:
username: aaaa
password: bbbb
connections:
console:
protocol: ssh
ip: y.y.y.y
port: 2222

router1:
os: iosxr
type: router
credentials:
default:
username: aaaa
password: bbbb
connections:
default:
protocol: telnet
ip: x.x.x.x
port: 23
sshtunnel:
host: linux1

I can connect to the router, but not able to execute any command after.

@vitodino vitodino reopened this Apr 22, 2020
@danielgraziano
Copy link
Contributor

danielgraziano commented Apr 22, 2020

Hi, it looks like you are combining two different methods - CLI Proxy and SSH Tunnel. The SSH Tunnel uses a server that is defined rather than a device. I suggest you do the following to use a device proxy instead:
image

Here are the differences:
https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/proxy.html#cli-proxy
https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/proxy.html#ssh-tunnel

@vitodino
Copy link
Author

@danielgraziano thanks for replying.
I've tried your suggestion (changing ssh tunnel to proxy) and still got the same issue. Could it be related to my python version? I've tried 3.7 and now I'm using 3.6.9.

@danielgraziano
Copy link
Contributor

@vitodino just to double check - is the routers hostname actually 'router1'? Or is that just an example? The reason I'm asking is the hostname and the name in your datafile must match otherwise it will hang after connecting

@vitodino
Copy link
Author

Hi @danielgraziano , sorry for my late response. I hadn't got the time to test the script again. it's working now by using the exact hostname on the testbed. Thanks a lot for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants