how to log connection refused attempt with python-paramiko
nickname
thebiggestbangtheory at gmail.com
Wed Sep 9 18:37:10 EDT 2009
On Sep 9, 3:35 pm, nickname <thebiggestbangthe... at gmail.com> 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)
> [/code]
>
> 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)
> [/code]
Update: I tried restarting ssh from /etc/init.d/ but no luck
More information about the Python-list
mailing list