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

Using current ssh environment when no username set #181

Open
ra-albrecht opened this issue Apr 30, 2024 · 2 comments
Open

Using current ssh environment when no username set #181

ra-albrecht opened this issue Apr 30, 2024 · 2 comments

Comments

@ra-albrecht
Copy link

Hi,,

I tried to use terraform for updating certificates on a remote host. Fort his ssh is required. Problem I have:

The remote provider enforces setting a user name. This can be a problem when multiple users work in the same environment because they have different usernames on a machine.

I am trying to understand why this is necessary. ssh knows much better how to handle this. E.g., when no username is set the connection string should not be

@:22

but

remotehost

(the need for the :22 when it is the standard port I don't understand, too, but ok)

The current behavior requires one extra configuration step, which wouldn't be needed when the standard behavior of ssh would be used.

example:

provider "remote" {
  alias = "swarm-master"
  max_sessions = 2
  conn {
    host = "swarm.XXXX.com"
    user = "remoteuser"
  }
}

could be (and should I think) be possible as

provider "remote" {
  alias = "swarm-master"
  max_sessions = 2
  conn {
    host = "swarm.XXXX.com"
  }
}

This would keep things in large environments much easier. Most times the users have in their personal ssh-config the correct username already set for a remote.

Would this change possible?

@gthieleb
Copy link

gthieleb commented May 3, 2024

You can workaround this with setting a variable in your shell session that exposes the current username.

export TF_VAR_remote_user=$USER
provider "remote" {
  alias = "swarm-master"
  max_sessions = 2
  conn {
    host = "swarm.XXXX.com"
    user = var.remote_user
  }
}

@ra-albrecht
Copy link
Author

Yes, of course, this is possible. But as said, it's an extra configuration step that should not be required. A fully configured SSH environment mostly exists and should be used instead.
In larger environments, this could make things much easier. Or when you use multiple accounts on multiple hosts you already set in your ssh-config.

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

2 participants