如何解决:Gcloud compute ssh SFATAL ERROR: No supported authentication methods available (server sent: pu
Posted
技术标签:
【中文标题】如何解决:Gcloud compute ssh SFATAL ERROR: No supported authentication methods available (server sent: publickey)【英文标题】:How to solve : Gcloud compute ssh SFATAL ERROR: No supported authentication methods available (server sent: publickey) 【发布时间】:2021-10-12 14:04:06 【问题描述】:我正面临这个著名的错误,经过多次研究,我可以使用以下方法为一台 VM 修复它:
print('ssh front-end begin')
host = "frontend-lab1"
cmd= f'gcloud compute ssh host --force-key-file-overwrite'
res = subprocess.check_output(cmd, shell=True)
cmd = f'gcloud compute ssh host --zone=europe-west1-b --command="cd /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/ && sudo echo \'NEXT_PUBLIC_API_URL=http://ip_back:4000\' | sudo tee /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/.env && sudo npm install pm2 -g && sudo npm run build && sudo pm2 --name counter-app start npm -- start"'
print(cmd)
res = subprocess.check_output(cmd, shell=True)
print(res)
print('ssh front-end end')
打开一个窗口并显示三个按钮,我可以在其中单击“是”并且它可以工作。
但是当我尝试使用其他虚拟机时(完全相同的配置,Ubuntu 20.04 lts 虚拟机)
print('ssh back-end begin')
host = "backend-lab1"
cmd= f'gcloud compute ssh host --force-key-file-overwrite'
res = subprocess.check_output(cmd, shell=True)
cmd = f'gcloud compute ssh host --zone=europe-west1-b --command="cd /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/ && sudo echo \'DATABASE_HOST=http://ip_db:3000\' | sudo tee /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/.env && sudo echo \'DATABASE_USER=postgres\' | sudo tee -a /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/.env && sudo echo \'DATABASE_USER=postgres\' | sudo tee -a /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/.env && sudo echo \'DATABASE_PASS=postgres\' | sudo tee -a /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/.env && sudo echo \'DATABASE_NAME=counter\' | sudo tee -a /home/jeromevialhes/mse-tsm-cloudsys-lab1/app/.env && sudo npm install pm2 -g && pm2 --name counter-api start npm -- start"'
print(cmd)
res = subprocess.check_output(cmd, shell=True)
print(res)
print('ssh back-end end')
我不断收到以下错误:
WARNING - POTENTIAL SECURITY BREACH!
The server's host key does not match the one PuTTY has
cached in the registry. This means that either the
server administrator has changed the host key, or you
have actually connected to another computer pretending
to be the server.
The new ssh-ed25519 key fingerprint is:
ssh-ed25519 255 99:f3:06:93:57:2d:8e:10:2b:4d:c3:18:90:aa:bc:00
If you were expecting this change and trust the new key,
enter "y" to update PuTTY's cache and continue connecting.
If you want to carry on connecting but without updating
the cache, enter "n".
If you want to abandon the connection completely, press
Return to cancel. Pressing Return is the ONLY guaranteed
safe choice.
Update cached key? (y/n, Return cancels connection) SFATAL ERROR: No supported authentication methods available (server sent: publickey)
我能做些什么来解决这个问题?如果我可以在代码中设置自动使用“是”选项,那就太好了。
【问题讨论】:
【参考方案1】:在 Google Cloud 中,您在创建、删除然后创建新的虚拟机实例时通常会获得相同的 IP 地址。这意味着相同 IP 地址的主机密钥将不同。
文件 ~/.ssh/known_hosts 包含按 IP 地址列出的主机列表。编辑文件,找到匹配 IP 地址的行并删除该行。然后重试 SSH。
在后台,CLI gcloud 调用 SSH (Linux) 或 Putty (Windows)。对于 Linux,您可以在执行 SSH 连接尝试之前执行命令 ssh-keygen -r host.example.com(或指定 IP 地址)来更新主机指纹。
【讨论】:
以上是关于如何解决:Gcloud compute ssh SFATAL ERROR: No supported authentication methods available (server sent: pu的主要内容,如果未能解决你的问题,请参考以下文章
错误:(gcloud.compute.ssh)[/usr/bin/ssh] 退出并返回代码 [255]
ERROR.(gcloud.compute.instance-groups.managed.rolling-action.replace)无法获取资源。(gcloud.compute.instance
ERROR.(gcloud.compute.instance-groups.managed.rolling-action.replace)无法获取资源。(gcloud.compute.instance