Tag Archives: Windows

How to add certificates to the Windows certificate store

There’s a command-line tool called certutil one can use to add (among other things) certificates to the certificate store in windows.

Some examples:

REM Add pfx-file to Personal
certutil -ent -p pfxpassword -importpfx my some.pfx

REM Add pfx-file to Trusted Root Certification Authorities
certutil -ent -p pfxpassword -importpfx root some.pfx

REM Add cer-file to Trusted Root Certification Authorities
certutil -ent -addstore root some.cer

Manage saved windows passwords

Logged into a windows share via explorer and hit the Remember Password option. Even though the login was accepted (and saved) it turned out I had used the wrong ad domain name…

Couldn’t find where to reset/change/”logout” again, but eventually found there’s a built-in command-line tool one can use for managing these saved passwords. Think I’ve seen a control panel type thing to do this too in the past, but just couldn’t find it today… Anyways, command-line is nice, so, using imaginary share \\foobar.int, here’s some stuff one can do:

> cmdkey /list
> cmdkey /list:foobar.int

> cmdkey /delete:foobar.int

> cmdkey /add:foobar.int /user:domain\username /pass

What’s running on port 80 in Windows?

Trying to set up Apache on a server, something is hogging port 80, but very “helpfully” the Resource Monitor just reports “System” with PID 4…

However, some commands found in a StackOverflow answer and its comments were helpful:

netsh http show urlacl
netsh http show servicestate
net stop http

Note: Do not just run these commands blindly and turn off services (in particular you should probably answer N when the last one asks…), but use them to identify what service(s) might be to blame. Then do an intelligent decision on whether the service is needed or not, before you potentially stop it and disable it…

Using SSH keys with GitHub / BitBucket / Azure DevOps on Windows

Couldn’t get this to work, but now it does, so… time for another “note to self”. 🙂

Prerequisites

  • Git, obviously…
  • PuTTY, with puttygen, plink and pageant, to be exact…

Setup

  1. Open puttygen.

  2. Either Load an existing private key, or Generate a new one.

  3. Copy the public key (“Public key for pasting …”) and add it to the git provider settings:

    • https://github.com/settings/keys
    • https://bitbucket.org/account/user/[username]/ssh-keys/
    • https://dev.azure.com/[organization]/_usersSettings/keys
  4. Open pageant.

  5. Load your private key.

  6. Check that the key authentication works with plink:

    plink -v git@github.com
    plink -v git@bitbucket.org
    plink -v git@ssh.dev.azure.com
  7. Set the GIT_SSH environment variable to C:\Program Files\PuTTY\plink.exe.

    ^^ This is the detail that so many StackOverflow answers and blog/forum posts didn’t mention. Without this, plink worked fine, but git commands still failed with authentication errors.

  8. (optional) Add a shortcut to the private key file to your startup folder. This way pageant will be automatically started, with your key, ready to go, whenever Windows boots up.

    start shell:startup

Usage

Now, as long as pageant is running with your private key loaded, it should work to clone, pull, push, etc., both to and from, both private and public git repositories. E.g. like this:

git clone git@github.com:example/some-private-repo.git

Note: If you’re asked to accept/store/cache a key, but pressing y doesn’t work, connect using putty first, which should give you a dialog with the same question which does work. Putty will complain/crash because there’s not actually an ssh shell to connect to, but that’s fine. After the key has been saved by putty, git should work fine. E.g. like this:

putty -ssh git@github.com

Sources: makandracards.com, vladmihalcea.com

Manual WAMP stack

For future reference…

PHP

  1. Download an x64 Thread Safe zip from php.net.
  2. Read the note about Visual C++ Redistributable in the sidebar of that download page, and install the one required for your version.
  3. Unzip somewhere and add to PATH.
  4. Pick a php.ini and adjust as necessary (enabled extensions, etc.).
  5. In particular, make sure the following is not commented out:
    extension_dir = "ext"
  6. Check that it works:
    php --version

Composer

  1. Download the Windows Installer from getcomposer.org.
  2. Run the installer..
  3. Check that it works:
    composer --version

Apache

  1. Download the Apache Win64 zip from apachelounge.com.
  2. Read the note about Visual C++ Redistributable above the downloads on that download page, and install the required one.
  3. Unzip somewhere and adjust httpd.conf as necessary (paths, enabled modules, etc.).
  4. Install as service:
    httpd.exe -k install
  5. Start the service.
  6. Check that it works:
    start http://localhost

Apache with PHP

  1. Add the following to httpd.conf.
    LoadModule php7_module C:/path/to/php/php7apache2_4.dll
    <IfModule php7_module>
        DirectoryIndex index.html index.php
        AddHandler application/x-httpd-php .php
        PHPIniDir "C:/path/to/php"
    </IfModule>
  2. Add an index.php to your DocumentRoot for testing, e.g.:
    <?php phpinfo();
  3. Restart the Apache service.
  4. Check that it works:
    start http://localhost

MariaDB

  1. Download a Windows x86_64 MSI Package via mariadb.org.
  2. Run the installer.
  3. Optionally add some of the following to my.ini under mysqld section:
    ; Only listen on localhost
    bind-address=127.0.0.1

    ; Enable logging of queries

    ; (probably bad in production, but very helpful for development debugging)
    general-log=1
    general-log-file=queries.log
    log-output=file
  4. Restart the service, if you changed anything in the ini.
  5. Check that it works by connecting with HeidiSQL or any other SQL client.