Python Forum
Paramiko resource shortage error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: Paramiko resource shortage error (/thread-25749.html)



Paramiko resource shortage error - michu7 - Apr-10-2020

I want to log into a router from a gateway switch and then pass commands to get the logs of the router

Made a script for the same butting receiving " Paramiko resource shortage error " \

### SCRIPT #### 

import paramiko
import getpass
import time

Host = "199.52.39.1"                                           ## This is the gateway IP 
username = "a2201471-3"
password = "RoXS5f+em9%Tjo="

ssh_client = paramiko.SSHClient()

ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect(hostname=Host, username=username, password=password)

print("Successfully Connected\n")

cmd = "Ssh -l gakr_mnsey 10.251.13.241"                    #### This is my username and the router IP

remote_connection = ssh_client.invoke_shell()

stdin, stdout, stderr = ssh_client.exec_command(cmd,get_pty=True) 

stdin.write('4cLs=P2j\n')

stdin.flush()
time.sleep(1)

stdin.write('sh ip bgp summ | b Nei\n')
stdin.flush()

remote_connection.send('sh ip bgp summ | b Nei\n')

print(stdout.read())
time.sleep(1)

ssh_client.close
##### Error ########

Error:
C:\Users\Gautham.Krishna\Desktop>g1.py Seccessfully Connected Secsh channel 1 open FAILED: : Resource shortage Traceback (most recent call last): File "C:\Users\Gautham.Krishna\Desktop\g1.py", line 21, in <module> stdin, stdout, stderr = ssh_client.exec_command(cmd,get_pty=True) File "C:\Users\Gautham.Krishna\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko-2.7.1-py3.8.egg\paramiko\client.py", line 508, in exec_command chan = self._transport.open_session(timeout=timeout) File "C:\Users\Gautham.Krishna\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko-2.7.1-py3.8.egg\paramiko\transport.py", line 875, in open_session return self.open_channel( File "C:\Users\Gautham.Krishna\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko-2.7.1-py3.8.egg\paramiko\transport.py", line 1017, in open_channel raise e paramiko.ssh_exception.ChannelException: ChannelException(4, 'Resource shortage')