Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to log connection refused attempt with python-paramiko

Reply
Thread Tools

how to log connection refused attempt with python-paramiko

 
 
nickname
Guest
Posts: n/a
 
      09-09-2009
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)
 
Reply With Quote
 
 
 
 
nickname
Guest
Posts: n/a
 
      09-09-2009
On Sep 9, 3:35*pm, nickname <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
nickname
Guest
Posts: n/a
 
      09-09-2009
On Sep 9, 3:37*pm, nickname <(E-Mail Removed)> wrote:
> On Sep 9, 3:35*pm, nickname <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Can't locate object method "first" via package "attempt" (perhaps you forgot to load "attempt"?) at .... GMI Perl Misc 3 06-19-2005 10:44 PM
Firefox, HOSTS file, and "Connection Refused" Captain Infinity Firefox 5 11-27-2004 04:50 PM
Help "The connection was refused" daniel Firefox 1 10-24-2003 07:28 AM
Another Macromedia problem -- Connection refused Stephen Cadwell Firefox 3 10-24-2003 07:27 AM



Advertisments