Giter VIP home page Giter VIP logo

azure-key-vault-plugin-gmsa's Introduction

Overview

The Container Credential Guard Azure Key Vault Plugin (CCGAKV Plugin) retrieves group managed service account (gMSA) credentials stored in Azure Key Vault to facilitate the domain-join process.

Requirements

On a domain controller, a gMSA for the container and a standard user account that is used to retrieve the gMSA password needs to be created. These credentials need to be stored in the Azure Key Vault in this format domain\user:password.

The key vault as well as the virtual machine (VM) that is being used to deploy the container need to have a managed identity assigned to them. For more information on managed identities please visit: https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview

How to deploy

Provide your credential spec file using the --security-opt parameter in docker run . For example:

docker run --security-opt "credentialspec=file://contoso_webapp01.json" --hostname webapp01 -it mcr.microsoft.com/windows/server:ltsc2022 powershell

Example credspec with gMSA enabled:

{
  "CmsPlugins": [
      "ActiveDirectory"
    ],
    "DomainJoinConfig": {
        "DnsName": "testing.com",
        "DnsTreeName": "testing.com",
        "Guid": guid of domain (use Get-ADDomain),
        "MachineAccountName": "test",
        "NetBiosName": "testing",
        "Sid": sid of domain (use Get-ADDomain)
    },
   "ActiveDirectoryConfig": {
        "GroupManagedServiceAccounts": [
            {
                "Name": "test",
                "Scope": "testing.com"
            },
            {
                "Name": "test",
                "Scope": "testing"
            }
        ],
        "HostAccountConfig": {
            "PluginGUID": "{CCC2A336-D7F3-4818-A213-272B7924213E}",
            "PluginInput": "ObjectId="objectid of managed identity";SecretUri="url of secret stored in keyvault",
            "PortableCcgVersion": "1"
        }
    }
}

To check that gMSA is working correctly, run the following command in the container:

# Replace contoso.com with your own domain
PS C:\> nltest /sc_verify:contoso.com

Flags: b0 HAS_IP  HAS_TIMESERV
Trusted DC Name \\dc01.contoso.com
Trusted DC Connection Status Status = 0 0x0 NERR_Success
Trust Verification Status = 0 0x0 NERR_Success
The command completed successfully

To verify the gMSA identity from within the container, run the following command and check the client name:

PS C:\> klist get webapp01

Current LogonId is 0:0xaa79ef8
A ticket to krbtgt has been retrieved successfully.

Cached Tickets: (2)

#0>     Client: webapp01$ @ CONTOSO.COM
        Server: krbtgt/webapp01 @ CONTOSO.COM
        KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
        Ticket Flags 0x40a10000 -> forwardable renewable pre_authent name_canonicalize
        Start Time: 3/21/2019 4:17:53 (local)
        End Time:   3/21/2019 14:17:53 (local)
        Renew Time: 3/28/2019 4:17:42 (local)
        Session Key Type: AES-256-CTS-HMAC-SHA1-96
        Cache Flags: 0
        Kdc Called: dc01.contoso.com

More details on deployment can be found here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/gmsa-run-container.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

azure-key-vault-plugin-gmsa's People

Contributors

judyliu-ms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

chemi0213

azure-key-vault-plugin-gmsa's Issues

Use of the AKV Plugin in a non-AKS Kubernetes distribution

Are there any examples of this plugin being used in a non-AKS Kubernetes implementation?

I was able to get the DLL compiled, however do not have any solid information on how to use it outside of the instructions provided for AKS, which I am not sure how to translate to "vanilla" kubernetes steps.

I am also unsure if the DLL I have compiled will work appropriately, considering there are no clear "instructions" on how to compile the code. The restore.cmd has an outdated branch for vcpkg, and to get it to run I had to update it to a new branch and make sure my PS was launched as administrator.

Here are the steps I followed to compile:

AKVCCGPLUGIN build steps.txt

A bit of background to provide context to my situation:

  • I am a Kubernetes Admin, with a primarily *nix Administration background and some development
  • I have limited knowledge/experience administering Windows systems
  • I have limited knowledge/experience administering AD
  • I have internal/external customers requesting gMSA in containers

As the demand for Windows based containers continues to grow and more organizations want to take advantage of gMSA in containers, are there plans to keep maintaining this project or providing a more generic ccg plugin capable of using other external key providers like Hashicorp Vault? Is there a pre-compiled generic version of the plugin AKV DLL available for download/use with instructions on how to implement? I feel that my use case is not unique, and I am looking for a way to work together to bridge some of the knowledge gaps that other admins with similar circumstances are undoubtedly going to encounter as more and more *nix shops adopt Kubernetes for container workloads.

Thank you for your time.
James M McKenzie

Additional Accounts / gMSA Support

Hello,

In https://github.com/MicrosoftDocs/Virtualization-Documentation/blob/live/windows-server-container-tools/ServiceAccounts/CredentialSpec.psm1 we see references to "gmsa3" an account residing in a child domain. I am attempting to get gMSA working over a domain trust (not a child domain). I have created a GMSA account in the other domain, however, I cannot figure out how to configure it, and how to keep the password in keyvualt.

The powershell script here suggests that I add the netbios/dns entry for the domain:

credspec:
ActiveDirectoryConfig:
GroupManagedServiceAccounts:
- Name: AppNpd_GMSA
Scope: MAINDOMAIN
- Name: AppNpd_GMSA
Scope: maindomain.local
- Name: AppNpd_GMSA
Scope: TRUSTDOMAIN
- Name: AppNpd_GMSA
Scope: trustdomain.local

However, I would expect the system needs the password/secret for the account as well; no?

Is my approach wrong? do I make multiple gmsa-spec files? never been done/never been tested?

Any assistance would be greatly appreciated!

KV plugin with the On-Premise Windows VM

Hi,

I just wanted to ask. Is it possible to use this plugin along with the On-Premise Windows Virtual Machine?

It seems that On-Premise VM cannot be assigned to Azure Managed Identity.

Is there any other way to utilize this plugin with On-Premise?

vcpkg version 2021.05.12 in restore.cmd out of date

When running restore.cmd, the mingw-w64-i686-libwinpthread package is not able to be installed:

Building package brotli[core]:x64-windows-static...
-- Downloading https://github.com/google/brotli/archive/e61745a6b7add50d380cfd7d3883dd6c62fc2c71.tar.gz -> google-brotli-e61745a6b7add50d380cfd7d3883dd6c62fc2c71.tar.gz...
-- Extracting source C:/Users/goliath/source/repos/Azure-Key-Vault-Plugin-gMSA/vcpkg/downloads/google-brotli-e61745a6b7add50d380cfd7d3883dd6c62fc2c71.tar.gz
-- Applying patch install.patch
-- Applying patch fix-arm-uwp.patch
-- Applying patch pkgconfig.patch
-- Applying patch fix-ios.patch
-- Using source at C:/Users/goliath/source/repos/Azure-Key-Vault-Plugin-gMSA/vcpkg/buildtrees/brotli/src/6c62fc2c71-7c6c2710e9.clean
-- Found external ninja('1.10.2').
-- Configuring x64-windows-static
-- Building x64-windows-static-dbg
-- Building x64-windows-static-rel
-- Downloading https://repo.msys2.org/mingw/i686/mingw-w64-i686-pkg-config-0.29.2-2-any.pkg.tar.zst -> msys-mingw-w64-i686-pkg-config-0.29.2-2-any.pkg.tar.zst...
-- Downloading https://repo.msys2.org/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://repo.msys2.org/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 22;"HTTP response code said error"
-- Downloading https://www2.futureware.at/~nickoe/msys2-mirror/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://www2.futureware.at/~nickoe/msys2-mirror/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 22;"HTTP response code said error"
-- Downloading https://mirror.yandex.ru/mirrors/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://mirror.yandex.ru/mirrors/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 22;"HTTP response code said error"
-- Downloading https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 22;"HTTP response code said error"
-- Downloading https://mirrors.ustc.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://mirrors.ustc.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 22;"HTTP response code said error"
-- Downloading https://mirror.bit.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://mirror.bit.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 6;"Couldn't resolve host name"
-- Downloading https://mirror.selfnet.de/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://mirror.selfnet.de/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 35;"SSL connect error"
-- Downloading https://mirrors.sjtug.sjtu.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst -> msys-mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst...
-- Downloading https://mirrors.sjtug.sjtu.edu.cn/msys2/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... Failed. Status: 22;"HTTP response code said error"
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:184 (message):

      Failed to download file.
      If you use a proxy, please set the HTTPS_PROXY and HTTP_PROXY environment
      variables to "https://user:password@your-proxy-ip-address:port/".

      If error with status 4 (Issue #15434),
      try setting "http://user:password@your-proxy-ip-address:port/".

      Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues

Call Stack (most recent call first):
  scripts/cmake/vcpkg_acquire_msys.cmake:90 (vcpkg_download_distfile)
  scripts/cmake/vcpkg_acquire_msys.cmake:138 (msys_package_download)
  scripts/cmake/vcpkg_find_acquire_program.cmake:446 (vcpkg_acquire_msys)
  scripts/cmake/vcpkg_fixup_pkgconfig.cmake:112 (vcpkg_find_acquire_program)
  ports/brotli/portfile.cmake:26 (vcpkg_fixup_pkgconfig)
  scripts/ports.cmake:142 (include)

I found this issue which explains the problem: microsoft/vcpkg#24028

Changing the tag value in the offending line to 2022.05.10 (the latest version as of now) solves the issue. Not sure if there's a version in between that would also work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.