<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic A Telnetlib Challenge: the telnet server does not require login credentials in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146706#M2106</link>
    <description>&lt;P&gt;The following python script connects you via telnet protocol to the specified telnet server. It works fine as long as the telnet server prompts for "Username: " and "Password: ". However, If the telnet server does not ask for credentials, this python script will fail.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question: How would fix the script so that it will also work when the remote telnet server does not ask for username or password?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the python script:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;telnetlib&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;getpass&lt;BR /&gt;&lt;BR /&gt;HOST = &lt;SPAN&gt;"192.168.0.101"&lt;BR /&gt;&lt;/SPAN&gt;user = &lt;SPAN&gt;input&lt;/SPAN&gt;(&lt;SPAN&gt;"Enter your username: "&lt;/SPAN&gt;)&lt;BR /&gt;password = getpass.getpass()&lt;BR /&gt;&lt;BR /&gt;tn = telnetlib.Telnet(HOST)&lt;BR /&gt;&lt;BR /&gt;tn.read_until(&lt;SPAN&gt;b"Username: "&lt;/SPAN&gt;)&lt;BR /&gt;tn.write(user.encode() + &lt;SPAN&gt;b"&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;password:&lt;BR /&gt;    tn.read_until(&lt;SPAN&gt;b"Password: "&lt;/SPAN&gt;)&lt;BR /&gt;    tn.write(password.encode() + &lt;SPAN&gt;b"&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tn.write(&lt;SPAN&gt;b"terminal length 0&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;tn.write(&lt;SPAN&gt;b"show version&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;tn.write(&lt;SPAN&gt;b"exit&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;output = tn.read_all()&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(output.decode())&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Sep 2020 02:00:06 GMT</pubDate>
    <dc:creator>googleboy</dc:creator>
    <dc:date>2020-09-05T02:00:06Z</dc:date>
    <item>
      <title>A Telnetlib Challenge: the telnet server does not require login credentials</title>
      <link>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146706#M2106</link>
      <description>&lt;P&gt;The following python script connects you via telnet protocol to the specified telnet server. It works fine as long as the telnet server prompts for "Username: " and "Password: ". However, If the telnet server does not ask for credentials, this python script will fail.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question: How would fix the script so that it will also work when the remote telnet server does not ask for username or password?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the python script:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;telnetlib&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;getpass&lt;BR /&gt;&lt;BR /&gt;HOST = &lt;SPAN&gt;"192.168.0.101"&lt;BR /&gt;&lt;/SPAN&gt;user = &lt;SPAN&gt;input&lt;/SPAN&gt;(&lt;SPAN&gt;"Enter your username: "&lt;/SPAN&gt;)&lt;BR /&gt;password = getpass.getpass()&lt;BR /&gt;&lt;BR /&gt;tn = telnetlib.Telnet(HOST)&lt;BR /&gt;&lt;BR /&gt;tn.read_until(&lt;SPAN&gt;b"Username: "&lt;/SPAN&gt;)&lt;BR /&gt;tn.write(user.encode() + &lt;SPAN&gt;b"&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;password:&lt;BR /&gt;    tn.read_until(&lt;SPAN&gt;b"Password: "&lt;/SPAN&gt;)&lt;BR /&gt;    tn.write(password.encode() + &lt;SPAN&gt;b"&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;tn.write(&lt;SPAN&gt;b"terminal length 0&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;tn.write(&lt;SPAN&gt;b"show version&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;tn.write(&lt;SPAN&gt;b"exit&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;output = tn.read_all()&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(output.decode())&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 02:00:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146706#M2106</guid>
      <dc:creator>googleboy</dc:creator>
      <dc:date>2020-09-05T02:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: A Telnetlib Challenge: the telnet server does not require login credentials</title>
      <link>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146714#M2107</link>
      <description>&lt;P&gt;If the remote server does not require login credentials, then you need to change the script based on the input method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try using your normal tool putty and secure CRT, and show us how you able to connect to the device ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 03:06:12 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146714#M2107</guid>
      <dc:creator>balaji.bandi</dc:creator>
      <dc:date>2020-09-05T03:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: A Telnetlib Challenge: the telnet server does not require login credentials</title>
      <link>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146788#M2108</link>
      <description>&lt;P&gt;What about an "if" statement that checks to see if the remote telnet server is requesting a username and a password?&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/286878"&gt;@balaji.bandi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;If the remote server does not require login credentials, then you need to change the script based on the input method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try using your normal tool putty and secure CRT, and show us how you able to connect to the device ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Sep 2020 14:13:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/a-telnetlib-challenge-the-telnet-server-does-not-require-login/m-p/4146788#M2108</guid>
      <dc:creator>googleboy</dc:creator>
      <dc:date>2020-09-05T14:13:38Z</dc:date>
    </item>
  </channel>
</rss>

