Skip to content
Discussion options

You must be logged in to vote

host.data.get("ssh_user") is the right call, and it does work when pyinfra actually knows the user. It returns the value if ssh_user is set in the inventory (("myhost", {"ssh_user": "deploy"})), in group data (group_data/all.py with ssh_user = "deploy"), or with --user/--ssh-user on the CLI, which gets put into override data. host.data.ssh_user and host.connector.data.get("ssh_user") give the same value. I checked all three on pyinfra 3.10 by building an Inventory + State through the API.

If you get None, you never set it in pyinfra. The username then comes from ~/.ssh/config (User, which pyinfra's SSH client reads when it connects) or from your local username. None of that is written bac…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@argh-tom
Comment options

Answer selected by argh-tom
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants