Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection doesn't respect/load project config #2264

Open
codebude opened this issue May 2, 2023 · 0 comments
Open

Connection doesn't respect/load project config #2264

codebude opened this issue May 2, 2023 · 0 comments

Comments

@codebude
Copy link

codebude commented May 2, 2023

Describe the bug
The Connection class ignores the ssh_config_path from project-level fabric.yml-file. The config is loaded to context correctly, but Connection does not pick it up.

To Reproduce
We have a fabric.yml at project/task level that contains ssh_config_path: resources/config and we have a task defined as:

from fabric import Connection
from invoke import task

@task
def say_hello(ctx):
    with Connection("my-server.de") as cxn:
        cxn.run(f"echo Hello world!")

The ssh-config at resources/config looks like:

Host my-server.de
    User root
    IdentityFile ~/.ssh/operator.key

Expected behaviour
We expect fabric/Connection to logon as root with the given key file. Instead we get:

File "/mnt/c/Users/codebude/Documents/Git/fabric/.venv/lib/python3.11/site-packages/paramiko/transport.py", line 1640, in auth_publickey
    return self.auth_handler.wait_for_response(my_event)

If we pass the config from context explicitly to the Connection constructor the connection works fine:

from fabric import Connection
from invoke import task

@task
def say_hello(ctx):
    with Connection("my-server.de", config=ctx.config) as cxn:
        cxn.run(f"echo Hello world!")

Alternative, if we set ssh_config_path: resources/config in the ~/.fabric.yml file in our home directory it also works. It's only broken, if we define it in the fabric.yml file that lays besides the fabfile.py.

Environment

  • Python 3.11.3
  • Fabric 3.0.1
  • Paramiko 3.1.0
  • Invoke 2.1.1
  • Client-OS: Windows 11
  • Target OS: Ubuntu 20.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant