mirror of
https://github.com/Mic92/sops-nix.git
synced 2026-05-13 16:38:45 +08:00
Add a converter from private ssh keys to age
This commit is contained in:
parent
4568162629
commit
6c916c1f57
6 changed files with 62 additions and 8 deletions
19
pkgs/ssh-privkey-to-age/default.nix
Normal file
19
pkgs/ssh-privkey-to-age/default.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{ stdenv, lib, buildGoModule, path, pkgs, vendorSha256, go }:
|
||||
buildGoModule {
|
||||
pname = "ssh-privkey-to-age";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ../..;
|
||||
|
||||
subPackages = [ "pkgs/ssh-privkey-to-age" ];
|
||||
|
||||
inherit vendorSha256;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Converter that converts SSH private keys into age keys";
|
||||
homepage = "https://github.com/Mic92/sops-nix";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ mic92 ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
28
pkgs/ssh-privkey-to-age/main.go
Normal file
28
pkgs/ssh-privkey-to-age/main.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/Mic92/sops-nix/pkgs/sops-install-secrets/agessh"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
println("Usage: " + os.Args[0] + " [path to ssh private key]")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
sshKey, err := ioutil.ReadFile(os.Args[1])
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Cannot read ssh key '%s': %w", os.Args[1], err))
|
||||
}
|
||||
|
||||
// Convert the key to bech32
|
||||
bech32, err := agessh.SSHPrivateKeyToBech32(sshKey)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("Cannot convert ssh key '%s': %w", os.Args[1], err))
|
||||
}
|
||||
fmt.Println(bech32)
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
{ stdenv, lib, buildGoModule, path, pkgs, vendorSha256, go }:
|
||||
buildGoModule {
|
||||
pname = "sops-ssh-to-age";
|
||||
pname = "ssh-pubkey-to-age";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ../..;
|
||||
|
||||
subPackages = [ "pkgs/sops-ssh-to-age" ];
|
||||
subPackages = [ "pkgs/ssh-pubkey-to-age" ];
|
||||
|
||||
inherit vendorSha256;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue