0

I'm trying to transfer one file from local machine to my VM in Computer Engine.

I'm running the following command:

gcloud compute scp test.txt instance-name:/usr/bin/

Then, after some second I get a message of connection timeout. Exited with return code 1.

Following this guide but as much stuff inside Google Cloud Tutorials, they're really sparse and superficial.

Anyway, I downloaded netcat and when I run

nc [EXTERNAL_IP] 22

I get no reponse... And there's no step beyond that...You're trapped... Any ideas?

  • default-allow-ssh is set to permitted on port 22.
  • ssh keys were generated.

** Edit 2019-04-11 - 14:15

While I was working with Windows environment, installed Debian for Windows subsystems, and with bash console, followed the same process, now I get this error:

enter image description here

** Edit 2019-04-11 - 14:33

Looks like the connection is not even hitting my VM firewall. Nothing is being logged at Stackdriver (it's active for the 'default-allow-ssh' recording ,but I don't know if something was supposed to be logged there).

** Edit 2019-04-11 - 15:52 Following the steps from Google Troubleshooting (startup script): https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh

I get this data, when I tried to log in: enter image description here

Firewall rules list: enter image description here

** Edit 16:55,

I tried almost every method displayed here https://cloud.google.com/compute/docs/instances/transfer-files#transfergcloud

Still no clue, there must be something blocking out my access.

Paulo Henrique
  • 489
  • 3
  • 15

2 Answers2

0

Looking the documentation about Using Firewall Rules, I can see that the default-allow-ssh only grant access to the instances that connecting from inside the network, but not from outside.

If you want to access from any outside network, you can add custom firewall rule pointing to your source IP.

amonaco
  • 70
  • 5
  • Hmmm... not sure... the default IP source is 0.0.0.0/0 which is meant to allow access from any IP source. Anyway, I added one rule to allow connections from my workstation IP (port 22). Still not working. Thanks! – Paulo Henrique Apr 11 '19 at 17:07
0

After struggling almost 2 days searching for a solution, this was my last resource: I've read somewhere that my ISP could be blocking my port 22, for some reason. So the problem was external.

The solution was to change my SSH port in my VW, here are the steps:

  • Connect to your SSH using Google default SSH console
  • Run: sudo nano /etc/ssh/sshd_config
  • Find the line where it says: #Port 22
  • Change it to your desired port, 445 for example and remove '#'
  • Save it then run sudo systemctl reload sshd.service to apply changes
  • Now, your workstation cmd, run: gcloud compute scp ./sometestfile.txt instance-name:/usr/bin --port=445

If you mess this out and can't access SSH console, click on the dropdown and select 'Open in browser window with customized port', then using your new port.

Phew! Hopes this helps someone...

Paulo Henrique
  • 489
  • 3
  • 15
  • You're probably seeing the same permission issue as in [this question](https://stackoverflow.com/q/27807018/3618671); see [my answer](https://stackoverflow.com/a/27889822/3618671) for a solution. – Misha Brukman Apr 19 '19 at 02:25