Fetch User Keys - simple tool for fetching SSH keys from various sources

Initial commit

hauleth.dev fe132d11

verified
+5
.gitignore
···
+
.devenv
+
+
# Added by cargo
+
+
/target
+67
README.md
···
+
# FUK
+
+
> No one gives a fuk… so you need to take it yourself.
+
+
**F**etch **U**ser **K**eys - simple tool for fetching SSH keys from various
+
sources.
+
+
## Sources
+
+
- [ ] Raw - no fetching, just raw key from the configuration
+
- [ ] Forges
+
+ [ ] GitHub
+
+ [ ] SourceHut
+
+ [ ] GitLab
+
+ [ ] Forgejo
+
+ [ ] Defining your own forges
+
- [ ] Host keys via `ssh-keyscan`
+
+
## Reason
+
+
In my case the reason was to be able to easily prepare set of SSH keys for use
+
with [agenix][], tool for managing secrets while working with Nix deployments.
+
However usage can be extended to other situations as well:
+
+
- Managing `allowed_signers` to check SSH signatures under commits and stuff
+
- Fetching `authorized_keys` to allow users to upload their keys without admin
+
manual intervention
+
+
## Usage
+
+
Define configuration file, for example `keys.toml` in form:
+
+
```toml
+
[[entry]]
+
name = "hauleth"
+
emails = [ "~@hauleth.dev" ]
+
keys = [
+
{ sourcehut = "~hauleth" },
+
{ github = "hauleth" }
+
]
+
+
[[entry]]
+
name = "heimdall"
+
keys = [
+
{ host = "heimdall" }
+
]
+
```
+
+
Now you can run
+
+
```sh
+
fuk keys.toml > keys.json
+
```
+
+
And get JSON document containing all keys provided by these:
+
+
```json
+
{
+
"hauleth": [
+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN7q0wm7C+EX0ORpRxeyhvWTT2BMPjSRQIZmbzPLIiHC"
+
],
+
"heimdall": [
+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC36MGQHLsmS1aUtRYyC40lguLR4/sRXDxwT8ieSkGgLFc95xQ/7m8tIYmtCTwIMvN9gzJkW6ufbWfuX1iBYoWVVO/QdJz/5/Nl4ZofyfdFSk4ZYaWSOnMlY7vV9K0L0WsEEf1R3Erf42Ek051PcO8IeTtYTxkaugrBOPSVmzBOZu9osnJbatCsODe7uIWRU8jd5gmL7a9pmk9Q8nWDDXzu4bWd9Dg1M1d+rIY368J4LNOzknPZUkOcK1TpLkutB6bozvaeKSBNaqihA0un1VETArhiUmUY6a0y5e34PNLQjbl5UqHS5tmU5jmolDIJV2hF78+XrgaZf+CNoQ1Ac3QJ",
+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEZsoYDw74ez/2YLPZMDQgN/KxyGiXHZt+CowWMiyoyL"
+
]
+
}
+
```
+270
flake.lock
···
+
{
+
"nodes": {
+
"devenv": {
+
"inputs": {
+
"flake-compat": "flake-compat",
+
"nix": "nix",
+
"nixpkgs": "nixpkgs",
+
"pre-commit-hooks": "pre-commit-hooks"
+
},
+
"locked": {
+
"lastModified": 1707004164,
+
"narHash": "sha256-9Hr8onWtvLk5A8vCEkaE9kxA0D7PR62povFokM1oL5Q=",
+
"owner": "cachix",
+
"repo": "devenv",
+
"rev": "0e68853bb27981a4ffd7a7225b59ed84f7180fc7",
+
"type": "github"
+
},
+
"original": {
+
"owner": "cachix",
+
"repo": "devenv",
+
"type": "github"
+
}
+
},
+
"flake-compat": {
+
"flake": false,
+
"locked": {
+
"lastModified": 1673956053,
+
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+
"owner": "edolstra",
+
"repo": "flake-compat",
+
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+
"type": "github"
+
},
+
"original": {
+
"owner": "edolstra",
+
"repo": "flake-compat",
+
"type": "github"
+
}
+
},
+
"flake-parts": {
+
"inputs": {
+
"nixpkgs-lib": "nixpkgs-lib"
+
},
+
"locked": {
+
"lastModified": 1706830856,
+
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=",
+
"owner": "hercules-ci",
+
"repo": "flake-parts",
+
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f",
+
"type": "github"
+
},
+
"original": {
+
"owner": "hercules-ci",
+
"repo": "flake-parts",
+
"type": "github"
+
}
+
},
+
"flake-utils": {
+
"inputs": {
+
"systems": "systems"
+
},
+
"locked": {
+
"lastModified": 1685518550,
+
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
+
"owner": "numtide",
+
"repo": "flake-utils",
+
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
+
"type": "github"
+
},
+
"original": {
+
"owner": "numtide",
+
"repo": "flake-utils",
+
"type": "github"
+
}
+
},
+
"gitignore": {
+
"inputs": {
+
"nixpkgs": [
+
"devenv",
+
"pre-commit-hooks",
+
"nixpkgs"
+
]
+
},
+
"locked": {
+
"lastModified": 1660459072,
+
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
+
"owner": "hercules-ci",
+
"repo": "gitignore.nix",
+
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
+
"type": "github"
+
},
+
"original": {
+
"owner": "hercules-ci",
+
"repo": "gitignore.nix",
+
"type": "github"
+
}
+
},
+
"lowdown-src": {
+
"flake": false,
+
"locked": {
+
"lastModified": 1633514407,
+
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
+
"owner": "kristapsdz",
+
"repo": "lowdown",
+
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
+
"type": "github"
+
},
+
"original": {
+
"owner": "kristapsdz",
+
"repo": "lowdown",
+
"type": "github"
+
}
+
},
+
"nix": {
+
"inputs": {
+
"lowdown-src": "lowdown-src",
+
"nixpkgs": [
+
"devenv",
+
"nixpkgs"
+
],
+
"nixpkgs-regression": "nixpkgs-regression"
+
},
+
"locked": {
+
"lastModified": 1676545802,
+
"narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=",
+
"owner": "domenkozar",
+
"repo": "nix",
+
"rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f",
+
"type": "github"
+
},
+
"original": {
+
"owner": "domenkozar",
+
"ref": "relaxed-flakes",
+
"repo": "nix",
+
"type": "github"
+
}
+
},
+
"nixpkgs": {
+
"locked": {
+
"lastModified": 1678875422,
+
"narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=",
+
"owner": "NixOS",
+
"repo": "nixpkgs",
+
"rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459",
+
"type": "github"
+
},
+
"original": {
+
"owner": "NixOS",
+
"ref": "nixpkgs-unstable",
+
"repo": "nixpkgs",
+
"type": "github"
+
}
+
},
+
"nixpkgs-lib": {
+
"locked": {
+
"dir": "lib",
+
"lastModified": 1706550542,
+
"narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=",
+
"owner": "NixOS",
+
"repo": "nixpkgs",
+
"rev": "97b17f32362e475016f942bbdfda4a4a72a8a652",
+
"type": "github"
+
},
+
"original": {
+
"dir": "lib",
+
"owner": "NixOS",
+
"ref": "nixos-unstable",
+
"repo": "nixpkgs",
+
"type": "github"
+
}
+
},
+
"nixpkgs-regression": {
+
"locked": {
+
"lastModified": 1643052045,
+
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
+
"owner": "NixOS",
+
"repo": "nixpkgs",
+
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
+
"type": "github"
+
},
+
"original": {
+
"owner": "NixOS",
+
"repo": "nixpkgs",
+
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
+
"type": "github"
+
}
+
},
+
"nixpkgs-stable": {
+
"locked": {
+
"lastModified": 1685801374,
+
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
+
"owner": "NixOS",
+
"repo": "nixpkgs",
+
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
+
"type": "github"
+
},
+
"original": {
+
"owner": "NixOS",
+
"ref": "nixos-23.05",
+
"repo": "nixpkgs",
+
"type": "github"
+
}
+
},
+
"nixpkgs_2": {
+
"locked": {
+
"lastModified": 1706173671,
+
"narHash": "sha256-lciR7kQUK2FCAYuszyd7zyRRmTaXVeoZsCyK6QFpGdk=",
+
"path": "/nix/store/ildml01gk7v91fba35whklllfi343lvq-source",
+
"rev": "4fddc9be4eaf195d631333908f2a454b03628ee5",
+
"type": "path"
+
},
+
"original": {
+
"id": "nixpkgs",
+
"type": "indirect"
+
}
+
},
+
"pre-commit-hooks": {
+
"inputs": {
+
"flake-compat": [
+
"devenv",
+
"flake-compat"
+
],
+
"flake-utils": "flake-utils",
+
"gitignore": "gitignore",
+
"nixpkgs": [
+
"devenv",
+
"nixpkgs"
+
],
+
"nixpkgs-stable": "nixpkgs-stable"
+
},
+
"locked": {
+
"lastModified": 1704725188,
+
"narHash": "sha256-qq8NbkhRZF1vVYQFt1s8Mbgo8knj+83+QlL5LBnYGpI=",
+
"owner": "cachix",
+
"repo": "pre-commit-hooks.nix",
+
"rev": "ea96f0c05924341c551a797aaba8126334c505d2",
+
"type": "github"
+
},
+
"original": {
+
"owner": "cachix",
+
"repo": "pre-commit-hooks.nix",
+
"type": "github"
+
}
+
},
+
"root": {
+
"inputs": {
+
"devenv": "devenv",
+
"flake-parts": "flake-parts",
+
"nixpkgs": "nixpkgs_2"
+
}
+
},
+
"systems": {
+
"locked": {
+
"lastModified": 1681028828,
+
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+
"owner": "nix-systems",
+
"repo": "default",
+
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+
"type": "github"
+
},
+
"original": {
+
"owner": "nix-systems",
+
"repo": "default",
+
"type": "github"
+
}
+
}
+
},
+
"root": "root",
+
"version": 7
+
}
+33
flake.nix
···
+
{
+
description = "Description for the project";
+
+
inputs = {
+
flake-parts.url = "github:hercules-ci/flake-parts";
+
nixpkgs.url = "flake:nixpkgs";
+
devenv.url = "github:cachix/devenv";
+
};
+
+
nixConfig = {
+
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
+
extra-substituters = "https://devenv.cachix.org";
+
};
+
+
outputs = inputs@{ flake-parts, ... }:
+
flake-parts.lib.mkFlake { inherit inputs; } {
+
imports = [
+
inputs.devenv.flakeModule
+
];
+
+
flake = {
+
+
};
+
+
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
+
+
perSystem = { inputs', ... }: {
+
devenv.shells.default = {
+
languages.rust.enable = true;
+
};
+
};
+
};
+
}