0

I want to make a script that asks the user for username and password and uses these for a few things at once, including connecting to OpenVPN without needing to either

  1. store the password on the disk
  2. ask the user for the data many times over

for example you can run net use with user and password to mount shares, however openVPN seemingly only has an option to pass a file with username and password.

On Linux there seemingly are solutions like this, however I don't seem to find anything similar for windows yet.

Is there a solution?

My1
  • 475
  • 5
  • 21
  • You can ask a user to input their password, which wll be held in a local variable for use throughout that cmd.exe session without it being stored in a file. Please open a Command Prompt window, type `set /?`, press the `[ENTER]` key, and read the usage information, paying particular note of the `/P` option. There are many examples of `Set /P` usage already on this site under the [[tag:batch-file]] tag, which you can use to adapt to your needs. – Compo Jun 03 '21 at 09:40
  • yes sure, but I need a way to pass that to openvpn, that is the problem. --auth-user-pass expects a file and I have not found any parameter – My1 Jun 03 '21 at 09:47
  • If your command expects a file, and you don't want to use a file, then you cannot do it! If the application has been updated to allow for a secure/encrypted password from a file, then that should be good enough, unless your other 'few things' do not accept that encrpted password from the same file. In that case, you'd need to use both a variable as already advised and an encrypted file. Either way, your issue appears to be with the capabilities of a specific piece of software, not a reproducible programming code problem, and may be better posed on [Super User](https://superuser.com) instead. – Compo Jun 03 '21 at 10:39
  • it does not allow a secure encrypted file. also at least in linux (as linked) there seems to be some way, at least there and I thought there might have been something for windows, if not than okay. – My1 Jun 03 '21 at 12:29
  • As I said, if it requires a file, and you don't want a file, _(probably for security reasons)_, and the utility has not been updated to accept an encrypted file, then what do you want us to help you with? It appears that you think that we're going to read and understand the process used in the Unix based link for you, then try to rewrite it to work exactly the same way in a Windows Operating System. That seems more like a request for a project, rather than assistance with a problematic piece of code, and as such would be off topic here. – Compo Jun 03 '21 at 12:35
  • I thought that maybe someone happened to know a similar trick, or maybe some other quirk in openVPN I am not aware of to do this. – My1 Jun 04 '21 at 07:46
  • https://stackoverflow.com/a/56202031/465183 – Gilles Quénot Jun 08 '21 at 00:31

0 Answers0