0

我想问一下如何解决当我尝试git clone ... 在容器中时由于服务器不在known_hosts中而失败的问题。有没有办法强制“是”:

The authenticity of host '192.168.0.136 (192.168.0.136)' can't be established.
ECDSA key fingerprint is SHA256:tZiiWJJYFdtTmjjk3kunA4dU3wI2WXPI/1O0EsMtIjk.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

我已经尝试过yes | git clone ...,但它不起作用

现在我正在这样做:

echo "github.com,140.82.121.3 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> /root/.ssh/known_hosts \

但是第一种方法看起来比在 Dockerfile 中更好

4

1 回答 1

1

您可以通过以下方式进行

ssh-keyscan github.com >> /root/.ssh/known_hosts
于 2021-03-04T09:33:35.250 回答