0

In our team we share a machine (and the same linux user) for developing on Linux. The Git repository is hosted on Azure. We now want everyone to use their own account when working on this machine and I'm told to do this with Personal Access Tokens. While I can see that this is a solution to work with authentication in general, I can't really see how to switch accounts quickly. It is possible that we'd need to do so several times a day, but the way I understand them, we'd have to also change the config and remote each time. I find this a bit cumbersome for a quick change.

Is there a fast(er) and more convenient way to handle this?

torek
  • 448,244
  • 59
  • 642
  • 775
Tare
  • 482
  • 1
  • 9
  • 25
  • One way would be to not use a credential manager, and enter the PAT every time, but I suppose you also want to avoid that. Depending on the credential manager you're using, though, you might be able to kill/reset it each time you want to switch PAT, and then you'll get prompted for the PAT at the next operation that needs it. – joanis Jun 24 '22 at 14:12
  • 1
    Each credential manager you use would have its own different way of being reset/killed, though, so if you want more details, you'll have to tell us what you use. But with `ps fux` you might be able to see the credential manager process, and kill it with `kill`. – joanis Jun 24 '22 at 14:15
  • This solution relies on the premise that your remote URL does not encode your username, just the repo, so that you are also prompted for the username on the first operation after killing the credential manager, and you rely on the credential manager to provide both the username and the PAT for subsequent operations. – joanis Jun 24 '22 at 14:18
  • By the way, the above should make sense if you're using `credential.helper=cache`, but probably not for other credential managers. – joanis Jun 24 '22 at 14:24
  • If you were not using Azure Repos, I'd recommend switching to SSH and letting each user log in with their own SSH agent forwarded. However, Azure Repos lacks a functional and secure SSH configuration, so that's not an option. – bk2204 Jun 24 '22 at 21:34
  • @joanis I haven't decided on a credential manager yet. Microsoft referenced one, so I wanted to look into that one, but I'm not dead set on it. Thanks for the input so far – Tare Jun 27 '22 at 06:44
  • @bk2204 actually I have used SSH access to those repos on a different machine (but I didn't have to switch users there). It works well enough so far. – Tare Jun 27 '22 at 06:45
  • You might also be able to manage your use case here with ssh keys. Each dev would have their own key on the machine with a password. When dev X uses the machine, they start their ssh-agent with their identity. Dev Y might be able to have a different agent running with their identity at the same time, or at worse Y has to kill X's agent before loading their own identity. – joanis Jun 27 '22 at 13:29
  • That is exactly what I'm going to try. It seems like the most convenient solution. Thank you. The forcing to switch is a bit of an issue, but if we don't restart the machine all the time and use the same linux user, I guess it would be the same problem, no matter how we switch the git user – Tare Jun 27 '22 at 13:34

0 Answers0