Home > Software engineering >  How to remove pipeline's access to self hosted agent (without the original PAT or access to the
How to remove pipeline's access to self hosted agent (without the original PAT or access to the

Time:07-09

Following are steps followed to setup the self hosted agent.

  1. Create a azure devops organization
  2. Create personal access token (PAT) with manage agent permissions
  3. Create an agent in azure devops
  4. On the target machine download the zip, unzip, run ./config.cmd
  5. Enter url, PAT

Now the agent is ready to be used for release pipeline deployments. Now I want to remove the agent so I run .\config remove. It asks me for the PAT which I don't remember.

I don't have access to the azure devops anymore (so cannot generate new PAT). My goal (ad this question) is regarding removal of the agent service from the machine. Whether or not it removes the agent from the azure devops is irrelevant. Any advise?

Maybe it is sufficient to just delete the C:\agent folder after the above command error?

enter image description here

CodePudding user response:

I will leave formal answer, just in case.

In your case, you do not have access to Azure DevOps longer and you are not able to generate or re-generate PAT token. No problem, it is not big issue, the agent software is a connection between your (a) Server and (b) Azure DevOps. So if you do not have access to Azure DevOps, you can not do any thing about it. What you need to focus on, is uninstalling the agent software from (a) Server so it is no longer connected to (b) Azure DevOps.

Normally to remove agent, just use .\config remove as you already have done in our question, and ignore server errors, the only reason server requires PAT again, is to allow removing the agent from Azure DevOps remotely, hence you do not have access Azure DevOps longer, just ignore the messages, it will removing the files. Delete the folder and that is it.

In case you get troubling or fail removing files using .\config remove, than you have to do manual removal. You have 2 options below:

  • If you have installed the agent as Service. Stop the service and deleting agent service in local system through: sc delete [service name].
  • If it is just running in command line. Stop the command line.

When one of the options is done. delete your agent folder. Now your Server is not longer connected to Azure DevOps. And you can use it for another Azure DevOps agent installation.

Reference:

  • Related