[smartmontools-support] How to encode $passwordEnc within smartd_mailer.conf.ps1 appropriately?
B.S.
bs27975+mailman-smartmontools-support at gmail.com
Fri Sep 1 22:49:28 CEST 2023
Wonderful! Thank you so much!
On Fri, Sep 1, 2023 at 12:17 PM Christian Franke
<Christian.Franke at t-online.de> wrote:
>
> B.S. wrote:
> > How do I munge my SMTP password appropriately for inclusion into my
> > smartd_mailer.conf.ps1 file?
>
> This encrypts the PW, folds the very long string and appends the setting
> to the config file:
>
> $password = '...'
> $sec = ConvertTo-SecureString -AsPlainText -Force $password
> $str = ConvertFrom-SecureString $sec
> $pwe = ($str -split '(.{78})' ` | Where-Object {$_}) -replace '^',' '
> '$passwordEnc = "', $pwe, '"' `
> | Out-File -Encoding "UTF8" -Append -FilePath "smartd_mailer.conf.ps1"
>
> I agree that such a script should be added to smartmontools package.
>
> This could be used to decrypt the PW later:
>
> $str = $passwordEnc -replace '[\r\n\t ]',''
> $sec = ConvertTo-SecureString -String $str
> $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec)
> [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
>
>
> The encryption is machine and user specific. If smartd is run as a
> service under the SYSTEM account, the above needs to be run on the same
> machine under this account, for example with 'psexec -s powershell'
> (Sysinternals tools).
>
> Alternatively run the service under a local user with admin privileges.
> Then the option '--warn-as-user=restricted' could be used. If specified,
> the smartd warning script is run under the same user but without admin
> privileges.
>
> Regards,
> Christian
>
More information about the Smartmontools-support
mailing list