how to log connection refused attempt with python-paramiko

Discussion in 'Python' started by nickname, Sep 9, 2009.

  1. nickname

    nickname Guest

    hello all,
    I am getting to grips with paramiko. I am trying to open a
    ssh connection to my server 127.0.0.1 using paramiko and want to
    specify the password via the program itself. I want to generate and
    change passwds via the program very frequently and hence am avoiding a
    key based approach.

    I am using

    Code:
    def send_ssh(ip):
      ssh = paramiko.SSHClient()
      ssh.connect('127.0.0.1', username='username', password='thispasswd',
    port=22)
    
    and I get

    Traceback (most recent call last):
    File "./client.py", line 76, in <module>
    send_ssh(ip)
    File "./client.py", line 46, in send_ssh
    ssh.connect('127.0.0.1', username='username',
    password='thispasswd', port=22)
    File "/var/lib/python-support/python2.5/paramiko/client.py", line
    299, in connect
    self._policy.missing_host_key(self, hostname, server_key)
    File "/var/lib/python-support/python2.5/paramiko/client.py", line
    83, in missing_host_key
    raise SSHException('Unknown server %s' % hostname)
    paramiko.SSHException: Unknown server 127.0.0.1

    The screen just "hangs", looks like it is waiting/timing-out and then
    if I use ctrl-C, it ouputs

    Exception exceptions.KeyboardInterrupt in <module 'threading' from '/
    usr/lib/python2.5/threading.pyc'> ignored

    In case I specify a different port, like 50000. I got a socket.error:
    (111, 'Connection refused') . Is there a log file where this is
    recorded. I looked up /var/log/auth.log and syslog, messages but could
    not find a reference to this erroneous login attempt.

    Code:
    def send_ssh(ip):
      ssh = paramiko.SSHClient()
      ssh.connect('127.0.0.1', username='testusername',
    password='thisshouldbethepasswd', port=50000)
    
     
    nickname, Sep 9, 2009
    #1
    1. Advertising

  2. nickname

    nickname Guest

    On Sep 9, 3:35 pm, nickname <> wrote:
    > hello all,
    >             I am getting to grips with paramiko. I am trying to open a
    > ssh connection to my server 127.0.0.1 using paramiko and want to
    > specify the password via the program itself. I want to generate  and
    > change passwds via the program very frequently and hence am avoiding a
    > key based approach.
    >
    > I am using
    >
    >
    Code:
    > def send_ssh(ip):
    >   ssh = paramiko.SSHClient()
    >   ssh.connect('127.0.0.1', username='username', password='thispasswd',
    > port=22)
    > 
    >
    > and I get
    >
    > Traceback (most recent call last):
    >   File "./client.py", line 76, in <module>
    >     send_ssh(ip)
    >   File "./client.py", line 46, in send_ssh
    >     ssh.connect('127.0.0.1', username='username',
    > password='thispasswd', port=22)
    >   File "/var/lib/python-support/python2.5/paramiko/client.py", line
    > 299, in connect
    >     self._policy.missing_host_key(self, hostname, server_key)
    >   File "/var/lib/python-support/python2.5/paramiko/client.py", line
    > 83, in missing_host_key
    >     raise SSHException('Unknown server %s' % hostname)
    > paramiko.SSHException: Unknown server 127.0.0.1
    >
    > The screen just "hangs", looks like it is waiting/timing-out and then
    > if I use ctrl-C, it ouputs
    >
    > Exception exceptions.KeyboardInterrupt in <module 'threading' from '/
    > usr/lib/python2.5/threading.pyc'> ignored
    >
    > In case I specify a different port, like 50000. I got a socket.error:
    > (111, 'Connection refused') . Is there a log file where this is
    > recorded. I looked up /var/log/auth.log and syslog, messages but could
    > not find a reference to this erroneous login attempt.
    >
    >
    Code:
    > def send_ssh(ip):
    >   ssh = paramiko.SSHClient()
    >   ssh.connect('127.0.0.1', username='testusername',
    > password='thisshouldbethepasswd', port=50000)
    > 


    Update: I tried restarting ssh from /etc/init.d/ but no luck
     
    nickname, Sep 9, 2009
    #2
    1. Advertising

  3. nickname

    nickname Guest

    On Sep 9, 3:37 pm, nickname <> wrote:
    > On Sep 9, 3:35 pm, nickname <> wrote:
    >
    >
    >
    > > hello all,
    > >             I am getting to grips with paramiko. I am trying to open a
    > > ssh connection to my server 127.0.0.1 using paramiko and want to
    > > specify the password via the program itself. I want to generate  and
    > > change passwds via the program very frequently and hence am avoiding a
    > > key based approach.

    >
    > > I am using

    >
    > >
    Code:
    > > def send_ssh(ip):
    > >   ssh = paramiko.SSHClient()
    > >   ssh.connect('127.0.0.1', username='username', password='thispasswd',
    > > port=22)
    > > 

    >
    > > and I get

    >
    > > Traceback (most recent call last):
    > >   File "./client.py", line 76, in <module>
    > >     send_ssh(ip)
    > >   File "./client.py", line 46, in send_ssh
    > >     ssh.connect('127.0.0.1', username='username',
    > > password='thispasswd', port=22)
    > >   File "/var/lib/python-support/python2.5/paramiko/client.py", line
    > > 299, in connect
    > >     self._policy.missing_host_key(self, hostname, server_key)
    > >   File "/var/lib/python-support/python2.5/paramiko/client.py", line
    > > 83, in missing_host_key
    > >     raise SSHException('Unknown server %s' % hostname)
    > > paramiko.SSHException: Unknown server 127.0.0.1

    >
    > > The screen just "hangs", looks like it is waiting/timing-out and then
    > > if I use ctrl-C, it ouputs

    >
    > > Exception exceptions.KeyboardInterrupt in <module 'threading' from '/
    > > usr/lib/python2.5/threading.pyc'> ignored

    >
    > > In case I specify a different port, like 50000. I got a socket.error:
    > > (111, 'Connection refused') . Is there a log file where this is
    > > recorded. I looked up /var/log/auth.log and syslog, messages but could
    > > not find a reference to this erroneous login attempt.

    >
    > >
    Code:
    > > def send_ssh(ip):
    > >   ssh = paramiko.SSHClient()
    > >   ssh.connect('127.0.0.1', username='testusername',
    > > password='thisshouldbethepasswd', port=50000)
    > > 

    >
    > Update: I tried restarting ssh from /etc/init.d/ but no luck


    Solved the problem using info from http://ubuntuforums.org/showthread.php?t=743119
     
    nickname, Sep 9, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gaurav tyagi
    Replies:
    0
    Views:
    5,034
    gaurav tyagi
    Mar 18, 2006
  2. sCHL
    Replies:
    1
    Views:
    541
    Patrick Meuser
    Aug 26, 2003
  3. =?ISO-8859-9?Q?Kadir_Karaca_Ko=E7er?=

    java.net.ConnectException: Connection refused

    =?ISO-8859-9?Q?Kadir_Karaca_Ko=E7er?=, May 6, 2004, in forum: Java
    Replies:
    6
    Views:
    82,052
    Gordon Beaton
    May 7, 2004
  4. VisionSet

    RMI - connection refused listener

    VisionSet, Sep 6, 2004, in forum: Java
    Replies:
    7
    Views:
    2,827
    Sudsy
    Sep 6, 2004
  5. GMI
    Replies:
    3
    Views:
    516
    Tad McClellan
    Jun 19, 2005
Loading...

Share This Page