【发布时间】: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)
我能做些什么来解决这个问题?如果我可以在代码中设置自动使用“是”选项,那就太好了。
【问题讨论】:
标签: python google-cloud-platform ssh google-cloud-python