-
Notifications
You must be signed in to change notification settings - Fork 344
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
StartShell default tcp port hardcoded #573
Comments
@miguelgr83 I agree we need to support the ability to handle a non-default port for StartShell(). We're looking into the best way to do that. For this particular example, I'm wondering why you're trying to invoke the CLI from the shell to then execute the ping command. Why not just invoke the ping RPC from PyEZ? |
Hi Stacy, The main reason of invoking the cli from the shell is that I really need the regular output of the "ping" command to attach it as evidence that the ip is reachable. Regards Miguel Garcia [email protected]:[email protected] On 10 Aug 2016, at 01:40, Stacy W. Smith <[email protected]mailto:[email protected]> wrote: @miguelgr83https://github.com/miguelgr83 I agree we need to support the ability to handle a non-default port for StartShell(). We're looking into the best way to do that. For this particular example, I'm wondering why you're trying to invoke the CLI from the shell to then execute the ping command. Why not just invoke the ping RPC from PyEZ? You are receiving this because you were mentioned. |
OK. Then could you just use: dev.cli('ping 10.7.240.114 count 5 rapid', warning=False) That would give you the ping output as CLI text over the existing NETCONF session rather than having to make a new SSH connection to the shell. --Stacy On Aug 9, 2016, at 11:46 PM, miguelgr83 <[email protected]mailto:[email protected]> wrote: Hi Stacy, The main reason of invoking the cli from the shell is that I really need the regular output of the "ping" command to attach it as evidence that the ip is reachable. Regards Miguel Garcia [email protected]:[email protected]:[email protected] On 10 Aug 2016, at 01:40, Stacy W. Smith <[email protected]mailto:[email protected]mailto:[email protected]> wrote: @miguelgr83https://github.com/miguelgr83 I agree we need to support the ability to handle a non-default port for StartShell(). We're looking into the best way to do that. For this particular example, I'm wondering why you're trying to invoke the CLI from the shell to then execute the ping command. Why not just invoke the ping RPC from PyEZ? You are receiving this because you were mentioned. — |
That command gives me an output error "command does not exist". Miguel Garcia [email protected]:[email protected] On 10 Aug 2016, at 01:59, Stacy W. Smith <[email protected]mailto:[email protected]> wrote: OK. Then could you just use: dev.cli('ping 10.7.240.114 count 5 rapid', warning=False) That would give you the ping output as CLI text over the existing NETCONF session rather than having to make a new SSH connection to the shell. --Stacy On Aug 9, 2016, at 11:46 PM, miguelgr83 <[email protected]mailto:[email protected]mailto:[email protected]> wrote: Hi Stacy, The main reason of invoking the cli from the shell is that I really need the regular output of the "ping" command to attach it as evidence that the ip is reachable. Regards Miguel Garcia [email protected]:[email protected]:[email protected]:[email protected] On 10 Aug 2016, at 01:40, Stacy W. Smith <[email protected]mailto:[email protected]mailto:[email protected]:[email protected]> wrote: @miguelgr83https://github.com/miguelgr83 I agree we need to support the ability to handle a non-default port for StartShell(). We're looking into the best way to do that. For this particular example, I'm wondering why you're trying to invoke the CLI from the shell to then execute the ping command. Why not just invoke the ping RPC from PyEZ? You are receiving this because you were mentioned. You are receiving this because you commented. You are receiving this because you were mentioned. |
Hi Vijay, This is the problem we're facing, it works for you as you're running default TCP/22 port for the SSH connection. If you have something like: Regards. .................................... [cid:346DD60A-941A-4CE3-9355-541BE1ED8BFB] m +1 (415) 608 7449 From: vijay-shetty <[email protected]mailto:[email protected]> @miguelgr83https://github.com/miguelgr83 It works fine on latest PyEZ code. `from jnpr.junos.utils.start_shell import StartShell dev = Device('10.x.x.x', user='User123', password='Pwd123') with StartShell(dev) as sh: print (value)` Output:- You are receiving this because you were mentioned. |
I don't know whether it is supposed to work or not. But, it is working for me. dev = Device('10.x.x.x', user='User123', password='Pwd123', port='8011') print ("port: ",dev.port ,"\n") with StartShell(dev) as sh: print (value) port: 8011 cli -c "ping 10.209.1.228 count 5 rapid" |
@vijay-shetty Its just printing the port value associated with Device class. StartShell starts a totally new connection and uses port 22 only |
@vnitinv Shouldn't it throw a warning or an error message? |
If it is a totally new connection it should honor ssh_config as well. On the other hand do we really need a separate connection? SSH channel should work just fine without additional hassle. Or do I miss something? |
This works for me:
|
Hi @miguelgr83
Thanks & Regards |
set the port ssh_client.connect port assigned in Device or if not assigned then set to default 22
set the port ssh_client.connect port assigned in Device or if not assigned then set to default 22
Fixed and merged |
Hi guys,
It seems the port is pre-stablished in the code when you try to perform a "start-shell" command
https://github.com/Juniper/py-junos-eznc/blob/master/lib/jnpr/junos/utils/start_shell.py#L78
I did some testing and I can confirm that it wont take "port" as a variable and it will always try to connect to tcp/22.
Do you think you can fix this in the future?
These are some tests I've done to confirm that.
This is regular PyEz and works
from jnpr.junos import Device
host_ip = "127.0.0.1"
port = "8011"
username = "miguel"
password = “Juniper"
dev = Device(host=host_ip, port=port, user=username, password=password)
dev.open()
This is my attempt to run Start Shell commands and does not work (it goes to the port 22 instead of the port 8011)
from jnpr.junos import Device
from jnpr.junos.utils.start_shell import StartShell
host_ip = "127.0.0.1"
port = "8011"
username = “miguel"
password = “Juniper"
dev = Device(host=host_ip, port=port, user=username, password=password)
dev.open()
ss = StartShell(dev)
ss.open()
ss.run('cli -c "ping 10.7.240.114 count 5 rapid”')
The reason it fails is because it goes against port 22 (linux ssh) and not port 8011 (mx port redirect).
Regards.
The text was updated successfully, but these errors were encountered: