You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you provide a minimal code example that causes the problem? And describe what happens when you use normal (open)ssh? I suspect you need a try except block.
hi, normal (open)ssh to the switch through command directly works well
suspect you need a try except block.
you mean i may try pass the error block?
minimal code:
here's the code in paramiko/channel.py
def _wait_for_event(self):
self.event.wait()
assert self.event.is_set()
if self.event_ready:
return
e = self.transport.get_exception()
if e is None:
e = SSHException('Channel closed.')
raise e
if it's not the code u want, plz let me know.
thanks for your help.
I mean your code, not the code in paramiko, so the shortest thing like
from paramiko import SSHClient
# do stuff
that causes the exception to happen. If "ryu" (whatever that is) is not your own code and you're not able to isolate the cause to a simple stand-alone script, it'd be best to talk to whoever wrote, supports or maintains it.
hi, sorry for the dumb reply.
yeah, i just use the library of the project "ryu"
so i don't really understand what's wrong with paramiko.
at least i'm sure that i can do ssh by command.
i already google it and try find solutions for a long time.
plz give me some instructions that i can try to solve this problem !
it'll certainly help me a lot, thanks!
here's my code:
from ryu.lib.of_config.capable_switch import OFCapableSwitch
import ryu.lib.of_config.classes as ofc
sess = OFCapableSwitch(
host='140.112.41.10',
port=4294967293,
username='admin',
password='pass',
unknown_host_cb=lambda host, fingeprint: True)
csw = sess.get()
for p in csw.resources.port:
print p.resource_id, p.current_rate
csw = sess.get_config('running')
for p in csw.resources.port:
print p.resource_id, p.configuration.admin_state
here's the code of ryu/ryu/contrib/ncclient/transport/ssh.py and the web url
1.
# REMEMBER to update transport.rst if sig. changes, since it is hardcoded there
def connect(self, host, port=830, timeout=None, unknown_host_cb=default_unknown_host_cb,
username=None, password=None, key_filename=None, allow_agent=True, look_for_keys=True):
"""Connect via SSH and initialize the NETCONF session. First attempts the publickey authentication method and then password authentication.
To disable attempting publickey authentication altogether, call with *allow_agent* and *look_for_keys* as `False`.
*host* is the hostname or IP address to connect to
*port* is by default 830, but some devices use the default SSH port of 22 so this may need to be specified
*timeout* is an optional timeout for socket connect
*unknown_host_cb* is called when the server host key is not recognized. It takes two arguments, the hostname and the fingerprint (see the signature of :func:`default_unknown_host_cb`)
*username* is the username to use for SSH authentication
*password* is the password used if using password authentication, or the passphrase to use for unlocking keys that require it
*key_filename* is a filename where a the private key to be used can be found
*allow_agent* enables querying SSH agent (if found) for keys
*look_for_keys* enables looking in the usual locations for ssh keys (e.g. :file:`~/.ssh/id_*`)
"""
if username is None:
username = getpass.getuser()
sock = None
for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
sock = socket.socket(af, socktype, proto)
sock.settimeout(timeout)
except socket.error:
continue
try:
sock.connect(sa)
except socket.error:
sock.close()
continue
break
else:
raise SSHError("Could not open socket to %s:%s" % (host, port))
t = self._transport = paramiko.Transport(sock)
t.set_log_channel(logger.name)
try:
t.start_client()
except paramiko.SSHException:
raise SSHError('Negotiation failed')
# host key verification
server_key = t.get_remote_server_key()
known_host = self._host_keys.check(host, server_key)
fingerprint = _colonify(hexlify(server_key.get_fingerprint()))
if not known_host and not unknown_host_cb(host, fingerprint):
raise SSHUnknownHostError(host, fingerprint)
if key_filename is None:
key_filenames = []
elif isinstance(key_filename, basestring):
key_filenames = [ key_filename ]
else:
key_filenames = key_filename
self._auth(username, password, key_filenames, allow_agent, look_for_keys)
self._connected = True # there was no error authenticating
c = self._channel = self._transport.open_session()
c.set_name("netconf")
(208)c.invoke_subsystem("netconf")
self._post_connect()
because the codes work well in a simulation environment, so i assume there maybe some problems with my computer settings, the python package, or the codes
when I try a normal ssh session, like : ssh [email protected]
then after i enter my password, i can get the permission into the management interface of switch
like this
Activity
Russell-Jones commentedon Apr 18, 2015
Could you provide a minimal code example that causes the problem? And describe what happens when you use normal (open)ssh? I suspect you need a try except block.
allen791210 commentedon Apr 18, 2015
hi, normal (open)ssh to the switch through command directly works well
suspect you need a try except block.
you mean i may try pass the error block?
minimal code:
here's the code in paramiko/channel.py
def _wait_for_event(self):
self.event.wait()
assert self.event.is_set()
if self.event_ready:
return
e = self.transport.get_exception()
if e is None:
e = SSHException('Channel closed.')
raise e
if it's not the code u want, plz let me know.
thanks for your help.
Russell-Jones commentedon Apr 18, 2015
I mean your code, not the code in paramiko, so the shortest thing like
that causes the exception to happen. If "ryu" (whatever that is) is not your own code and you're not able to isolate the cause to a simple stand-alone script, it'd be best to talk to whoever wrote, supports or maintains it.
allen791210 commentedon Apr 18, 2015
hi, sorry for the dumb reply.
yeah, i just use the library of the project "ryu"
so i don't really understand what's wrong with paramiko.
at least i'm sure that i can do ssh by command.
i already google it and try find solutions for a long time.
plz give me some instructions that i can try to solve this problem !
it'll certainly help me a lot, thanks!
here's my code:
here's the code of ryu/ryu/contrib/ncclient/transport/ssh.py and the web url
1.
Russell-Jones commentedon Apr 18, 2015
You should raise this on the ryu mailing list https://lists.sourceforge.net/lists/listinfo/ryu-devel , though check the archives first. https://github.com/osrg/ryu They can help you establish if it's a paramiko issue, or something to do with how you're using ryu.
You didn't answer my question about what happens when you try a normal ssh session.
Oh, and for IPv4 port numbers only go up to 65535, so the long number you have may not be valid: http://stackoverflow.com/questions/113224/what-is-the-largest-tcp-ip-network-port-number-allowable-for-ipv4
The address suggests you're not using IPv6, though perhaps you should be if that's the port number you've been given? I don't know what the limits on ports in IPv6 are, having said that.
allen791210 commentedon Apr 18, 2015
sorry for not upload the latest code
the port number is : 22 and it shows that i pass the authentication (successful) in the first msg
Actually, i already check all the problems in mailing list and post my problem as well. (still no any response) http://sourceforge.net/p/ryu/mailman/message/33860755/
because the codes work well in a simulation environment, so i assume there maybe some problems with my computer settings, the python package, or the codes
when I try a normal ssh session, like : ssh [email protected]
then after i enter my password, i can get the permission into the management interface of switch
like this
source-ram commentedon Sep 1, 2017
Any fix available ?
mrts commentedon Dec 28, 2018
In case you are trying to use SFTP this may be caused by the SFTP subsystem being disabled in the remote host.
To enable the SFTP subsystem, uncomment the following line in
/etc/ssh/sshd_configand restart thesshdservice: