LnL7 / nix-docker

Docker images for the Nix package manager
MIT License
288 stars 41 forks source link

SSL peer certificate or SSH remote key was not OK #32

Closed knl closed 4 years ago

knl commented 4 years ago

On a freshly set up system, I see this:

ssh dfinity-nix-docker
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
-bash-4.4# nix-env -iA nixos.curl
installing 'curl-7.68.0'
warning: unable to download 'https://cache.nixos.org/lxw9pidjbdhpg4izygyr8khrzjzfydz9.narinfo': SSL peer certificate or SSH remote key was not OK (60); retrying in 341 ms
...

This usually implies that NIX_SSL_CERT_FILE is not properly set. If I check on the machine:

$ printenv
SSH_CONNECTION=172.17.0.1 47240 172.17.0.2 22
USER=root
NIX_PATH=nixpkgs=/nix/store/p2d6ih9sz4whijgf9i5jvy4g9hycfb02-nixpkgs-20.09pre216190.6b6f9d769a5
PWD=/root
HOME=/root
SSH_CLIENT=172.17.0.1 47240 22
SSL_CERT_FILE=
SSH_TTY=/dev/pts/0
MAIL=/var/mail/root
TERM=xterm-256color
SHELL=/run/current-system/sw/bin/bash
SHLVL=1
LOGNAME=root
PATH=/root/.nix-profile/bin:/run/current-system/sw/bin
_=/run/current-system/sw/bin/printenv

The variable is not there, and SSL_CERT_FILE is empty. Checking /etc/bashrc shows the following:

$ cat /etc/bashrc
export SSL_CERT_FILE=
export PATH=/root/.nix-profile/bin:/run/current-system/sw/bin
export NIX_PATH=nixpkgs=/nix/store/p2d6ih9sz4whijgf9i5jvy4g9hycfb02-nixpkgs-20.09pre216190.6b6f9d769a5

Thus, I think this is a bug. My wild guess would be that sshDocker defines SSL_CERT_FILE=$SSL_CERT_FILE (here), yet image only exports NIX_SSL_CERT_FILE (here). In f750cee621610b0b5718afcf20f922c39a3a6da0 image has been changed to export NIX_SSL_CERT_FILE instead of SSL_CERT_FILE.

LnL7 commented 4 years ago

Thanks, haven't used the ssh image in a while so didn't notice this. Fixed with the latest update.