mwilliamson / spur.py

Run commands and manipulate files locally or over SSH using the same interface
BSD 2-Clause "Simplified" License
267 stars 37 forks source link

No password authentication #17

Closed DerpDarako closed 9 years ago

DerpDarako commented 10 years ago

Hello,

When I execute this:

shell = spur.SshShell(hostname='IP', username='admin', password='password') shell.run('sh ver')

I always get : spur.ssh.ConnectionError: Error creating SSH connection Original error: Authentication failed.

From my router, I see public key authentication.

Are you sure to set up look_for_keys to false?

mwilliamson commented 10 years ago

I always get : spur.ssh.ConnectionError: Error creating SSH connection Original error: Authentication failed.

Presumably using the username and password from the command line does work?

From my router, I see public key authentication.

Sorry, I don't understand what you mean by this.

Are you sure to set up look_for_keys to false?

If you mean the look_for_keys argument to paramiko's connect function, then Spur doesn't set a value i.e. it uses the default. From the error, it looks as if the credentials you're trying to use are being rejected. If you don't need to use a password, then there's no need to set it.

DerpDarako commented 10 years ago

Hello,

I tested paramiko and i'm unable to connect to my router if I don't set look_for_keys to False.

Sorry, I don't understand what you mean by this.

My script is trying to connect to router so I can read router's log when I execute the script. Anyway, I see this:

SSH authentication method : publickey

When it works I see:

SSH authentication method : password

But if I want to see this with paramiko I have to set look_for_keys to False...

Whatever, it's not an issue! This option is just missing.

Thank you for your quick reply:)

mwilliamson commented 10 years ago

Ah, I see. Although it's a small change, I probably won't have time to add the relevant option to spur for at least a few days. Still not entirely sure why look_for_keys needs to be set to False though -- I'd expect the password to be used if the private key doesn't work, but I'm not SSH expert.

Does running the equivalent ssh command on the command line work?

DerpDarako commented 10 years ago

Hello,

Yes, it weird than paramiko doens't use the password if no private key is set. I have to problem for connecting with "ssh admin@ip".

Sorry for my late reply !

mwilliamson commented 10 years ago

I have to problem for connecting with "ssh admin@ip".

So when you try using "ssh admin@ip", you're asked for a password, which the host accepts?

DerpDarako commented 10 years ago

Oops! My bad!

When i use ssh admin@ip, it works fine, I get a prompt then I enter my password and I'm connected! So I have no problem if I use command line.

mwilliamson commented 9 years ago

I've added a look_for_private_keys argument to SshShell, which can be set to False, which should fix this issue. Sorry for keeping this open so long!

DerpDarako commented 9 years ago

Thank you :)