poshbotio / PoshBot

Powershell-based bot framework
MIT License
539 stars 108 forks source link

Poshbot doesn't work after adding PSCredential to existing configuration and running as a service. #144

Closed mgeorgebrown89 closed 5 years ago

mgeorgebrown89 commented 5 years ago

I have an existing config file for poshbot. I used nssm to run it as a service. Everything works great. I wanted to add a PSCredential to the config file. The documentation only has stuff for adding one to a new configuration, but I figured I could Get-PoshBotConfiguration and edit the field with my constructed credentials. It seemed to work when I saved the configuration, (it looked just like the example--a really long encrypted string) but when I restarted the service in order to reload the config file, it stopped responding. I confirmed this was the issue, because when I commented out the portion added to the congfig r

Expected Behavior

If I get an existing configuration, I should be able to edit it, specifically adding a PS Credential and have it still connect to slack.

Current Behavior

If I edit the config by adding a pscredential, it stops responding.

Steps to Reproduce (for bugs)

  1. Create a poshbot configuration. 2.Create a service using this configuration. 3.Edit this configuration by adding a PSCredential object. 4.Restart the service.

Windows Server 2012 R2. PS 5.1

ChrisLGardner commented 5 years ago

Which user is the service running as? If it's not the same one as generated the secure string then it won't be able to decrypt it as it's protected by DPAPI. there are ways around it but the simplest is to log on as that user and update the config from there.


From: Michael G. Brown notifications@github.com Sent: Friday, February 8, 2019 7:52:07 PM To: poshbotio/PoshBot Cc: Subscribed Subject: [poshbotio/PoshBot] Poshbot doesn't work after adding PSCredential to existing configuration and running as a service. (#144)

I have an existing config file for poshbot. I used nssm to run it as a service. Everything works great. I wanted to add a PSCredential to the config file. The documentation only has stuff for adding one to a new configuration, but I figured I could Get-PoshBotConfiguration and edit the field with my constructed credentials. It seemed to work when I saved the configuration, (it looked just like the example--a really long encrypted string) but when I restarted the service in order to reload the config file, it stopped responding. I confirmed this was the issue, because when I commented out the portion added to the congfig r

Expected Behavior

If I get an existing configuration, I should be able to edit it, specifically adding a PS Credential and have it still connect to slack.

Current Behavior

If I edit the config by adding a pscredential, it stops responding.

Steps to Reproduce (for bugs)

  1. Create a poshbot configuration. 2.Create a service using this configuration. 3.Edit this configuration by adding a PSCredential object. 4.Restart the service.

Windows Server 2012 R2. PS 5.1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/poshbotio/PoshBot/issues/144, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQDqFh7UyvEAiHeLx_q5a-L3AWy3zFA9ks5vLdVngaJpZM4axUBu.

devblackops commented 5 years ago

@ChrisLGardner 💯

Credentials saved to disk are only retrievable by the original user who exported them. If you're running PoshBot as some type of service account, you'll need to log on as that to save/export/update them.

mgeorgebrown89 commented 5 years ago

Ah. that's similar to my last issue.

Thanks, @ChrisLGardner and @devblackops .