Nixos

使用 nix-serve 作為二進制記憶體時出現“錯誤:公鑰無效”的客戶端 nixos 錯誤

  • September 29, 2019

我遇到了以下錯誤error: public key is not valid

[demo@nixos:~]$ nix-env -i ripgrep
installing 'ripgrep-0.10.0'
these paths will be fetched (0.00 MiB download, 4.76 MiB unpacked):
 /nix/store/xgr3frnb5f13sf3ich8hl8lqbwjqngw9-ripgrep-0.10.0
error: public key is not valid

[demo@nixos:~]$ sudo nix-env -i ripgrep
installing 'ripgrep-0.10.0'
these paths will be fetched (0.00 MiB download, 4.76 MiB unpacked):
 /nix/store/xgr3frnb5f13sf3ich8hl8lqbwjqngw9-ripgrep-0.10.0
error: public key is not valid

我的客戶端 Nixos 中有以下設置:

 nix = {
   binaryCaches = [
     "https://cache.nixos.org/"
     "http://192.168.56.1:8080"
   ];
   binaryCachePublicKeys = [
     "my-nix-cache:aDrIoY93RjzjnMmNYXlKSL3OerPqIGEiqv70CzwWzQvPejwp/89PN6FWkywTYqhjJ/muRT9cJHT4B8S+0pKCjw="
   ];
   trustedUsers = [ "root" "chris" ];
 };

nix-serve我正在做的伺服器上:

NIX_SECRET_KEY_FILE="/etc/nixos/nixkeys/key.private" nix-serve -p 8080   
2019/09/29-20:44:00 Starman::Server (type Net::Server::PreFork) starting! pid(17383)
Resolved [*]:8080 to [0.0.0.0]:8080, IPv4
Binding to TCP port 8080 on host 0.0.0.0 with IPv4
Setting gid to "100 100 1 17 27 67 100 131"
cat /etc/nixos/nixkeys/key.public 
my-nix-cache:z3o8Kf/PTzehVpMsE2KoYyf5rkU/XCR0+AfEvtKSgo8=

我剛剛意識到:

my-nix-cache:z3o8Kf/PTzehVpMsE2KoYyf5rkU/XCR0+AfEvtKSgo8=字元串與我在公鑰中的內容不匹配:

my-nix-cache:aDrIoY93RjzjnMmNYXlKSL3OerPqIGEiqv70CzwWzQvPejwp/89PN6FWkywTYqhjJ/muRT9cJHT4B8S+0pKCjw=

…修復使其工作:)

我複制了私鑰而不是公鑰!

引用自:https://unix.stackexchange.com/questions/544361