Hello,
I was able to access my Windows 2022 server imaged VM using ssh from my macbook regardless of ssh key registration, with the tools - google-compute-engine-ssh and option.
However, couldn't do scp even the manual is saying that I should be able to scp if the VM is SSH enabled. Any clue?
/usr/bin/scp: Connection closed
ERROR: (gcloud.compute.scp) [/usr/bin/scp] exited with return code [255].
Hello @jerryum,
Welcome to Google Cloud Community!
Since you can connect to your VM using SSH, I presume port 22 is already allowed on your firewall. SCP is also using the same port as SSH (port 22) but you might want to check if scp is running on a custom or different port.
If yes, you must create a custom firewall rule allowing tcp traffic on the port that your scp is running on using the following command:
gcloud compute firewall-rules create FIREWALL_NAME \
--allow tcp:PORT_NUMBER
For more info about creating custom firewall rules, see Creating firewall rules.
This is likely due to OpenSSH 9.0 deprecating the scp protocol [1] in your macOS version.
I encountered the same/similar issue and confirmed passing the '-O' option directly to my local scp binary (`/usr/bin/scp`) on macOS Sonoma 14.0 (23A344) allows successful file transfers to a properly-configured Windows server [2].
To get the gcloud-wrapped version [3] to work, add the flag `--scp-flag=-O` to your command.
gcloud compute scp /path/to/local/file user@windows-instance:"C:\Users\Public" \
--project=my-project \
--zone=us-central1-a \
--scp-flag=-O
This could be a security concern. Use caution when forcing deprecated protocols.
[1] https://apple.stackexchange.com/questions/451281/unable-to-scp-since-upgrade-to-ventura
[2] https://cloud.google.com/compute/docs/connect/windows-ssh
[3] https://cloud.google.com/sdk/gcloud/reference/compute/scp#--scp-flag