Reputation: 17358
I'm running a google cloud instance. I'm able to successfully connect to the instance via ssh.
But I'm not able to do the port forwarding to my localhost.
Here's the command I used:
ssh -L 16006:127.0.0.1:8080 username@instance_external_ip
When I run the above command , I get the following error
The authenticity of the host cannot be determined.
username@instance_external_ip : Permission Denied (public key)
How to solve this problem?
Upvotes: 1
Views: 3037
Reputation: 17358
I found the answer for this question. The problem I had was that the server did not know the ssh keys. So, I did the following and it worked.
I deleted all the ssh keys in the my local machine and connect to my gcloud instance using the following command. gcloud command creates the ssh keys automatically and it transfers to the cloud ssh keys automatically. So, no need to manually copy paste the keys.
gcloud compute --project "project_name" ssh --zone "zone_name" "instance_name"
After this I connected to my instance using ssh. Before doing if you try to ssh tunnel , as the server won't be aware of the localhost, it will say permission denied on running ssh -L ....
.
Therefore, instead of directly connecting through ssh -L ...
, connect along with ssh-key
file stored in .ssh
directory. Use the following command.
ssh -i ~/.ssh/google_compute-engine -L <ur localhost port number>:127.0.0.1:<remote_host_port> username@server_ip
Upvotes: 4