how to log connection refused attempt with python-paramiko

N

nickname

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)
 
N

nickname

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
 
N

nickname

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top