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

Server 'localhost' not found in known_hosts #43

Closed hefq343 closed 8 years ago

hefq343 commented 8 years ago

import spur shell = spur.SshShell(hostname="localhost", username="bob", password="password1") with shell: result = shell.run(["echo", "-n", "hello"]) print(result.output) # prints hello

Traceback (most recent call last): File "help.py", line 5, in result = shell.run(["echo", "-n", "hello"]) File "build/bdist.linux-x86_64/egg/spur/ssh.py", line 160, in run File "build/bdist.linux-x86_64/egg/spur/ssh.py", line 171, in spawn File "build/bdist.linux-x86_64/egg/spur/ssh.py", line 249, in _get_ssh_transport spur.ssh.ConnectionError: Error creating SSH connection Original error: Server 'localhost' not found in known_hosts

what is the matter?

mwilliamson commented 8 years ago

The last line of the error states that localhost is not found in known_hosts: by default, spur will not allows connections to unknown hosts since it's insecure. You'll need to either add localhost as a known host, or use the missing_host_key argument to change the behaviour when the host isn't found: see the documentation for more details.

mwilliamson commented 8 years ago

Closing since it looks like Spur is working as intended, feel free to shout if you think something's broken.