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

SSH config 'user' value is ignored in execute() #1537

Open
stefanha opened this issue Dec 10, 2016 · 1 comment
Open

SSH config 'user' value is ignored in execute() #1537

stefanha opened this issue Dec 10, 2016 · 1 comment

Comments

@stefanha
Copy link

The following lines in network.py:normalize() cause the SSH config 'user' value to be ignored when the task is invoked via execute():

# Only use ssh_config values if the env value appears unmodified from
# the true defaults. If the user has tweaked them, that new value
# takes precedence.
if user == env.local_user and 'user' in conf:
    user = conf['user']

The parent task may have a user value that differs from env.local_user so the if condition is False.

The following fabfile reproduces the bug:

from fabric.api import *

@hosts('host2')
def a():
    print env.user

def b():
    execute('a')

# When .ssh/config has:
# Host host1
# User user1
# Host host2
# User user2
#
# Output:
# $ fab -H host1 a
# user2
# $ fab -H host1 b
# user1
#
# A different user value is set depending on whether task 'a' was invoked from
# the command-line or via execute()!
#
# The expected output is:
# $ fab -H host1 b
# user2
@stefanha
Copy link
Author

After discussing with redkrieg on IRC I think comparing against a user value in network.py:normalize() is wrong in the first place. If the user manually overrides env.user but happens to use same username as env.local_user they're not supposed to get the ssh config User value, but the current code will treat it as if it's okay to apply ssh config User.

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