SFTP (FileZilla) to GCP Private VM (Internal IP)

Hello,

I am a newbie to gcp and I want to make the SFTP connection from FileZilla/WinSCP (running in personal laptop) to GCP private VM (using internal IP only, dont have external IP to this VM), so can someone please help resolving this issue?

I am able to SSH (using Putty) to the private VM using its internal IP address through IAP, but somehow unable to SFTP to the same private VM.

Your help is highly appreciated.

Thank you.

Solved Solved
2 5 627
2 ACCEPTED SOLUTIONS

Did you maybe tried to establish ssh connection from shell but with different port and then from SFTP client connect to your server? 

I've configured IAP for this server and removed publicIP and configured sftp by this article https://www.techrepublic.com/article/how-to-set-up-an-sftp-server-on-linux/

Steps to connect:

1. Establish tunnel from your laptop
gcloud compute start-iap-tunnel VM_NAME 22 --local-host-port=localhost:2222 --zone=us-central1-a (provide zone, where you have VM provisioned)

DamianS_1-1708367700556.png

 

2. Establish connection by doing sftp to localhost and provided port (screenshot taken from FileZilla

DamianS_2-1708367745357.png

3. sftp via CLI

DamianS_3-1708367797871.png

cheers,
DamianS

 

View solution in original post

Hi @DamianS , I did tcp port forwarding for port 22 on private VM, then used the SFTP client to connect to the private VM using private IP & forwarded port, and that resolved the issue...

Thank you,

TekXplorer

View solution in original post

5 REPLIES 5

Hello @TekXplorer ,

Most probably you don't have configured FW rule for allow SFTP to your VM. Most probably you should add SFTP rule to your FW and then 
1. Establish tunnel via IAP to your VM at GC
2. Then try to use SFTP commander or such to deal with files.
3. If you are using Windows, look at this https://github.com/GoogleCloudPlatform/iap-desktop

cheers,
DamianS

Thank you @DamianS,

I do have FW rules open as below but still unable to SFTP from WinSCP or FileZilla.

I have firewall open for port 22/tcp in project VPC with allowed source IP ranges 0.0.0.0/0.

Also, I have opened the port 22/tcp in the target VM from the shell using firewall-cmd command.

Also, like I mentioned before, I am able to do SSH to the same VM from my laptop but SFTP doesn't work.

When I try to connect, it gives error like "Server unexpectedly closed network connection."

Can you guide me what could be wrong in my configuration, please?

Thank you for your quick response.

Did you maybe tried to establish ssh connection from shell but with different port and then from SFTP client connect to your server? 

I've configured IAP for this server and removed publicIP and configured sftp by this article https://www.techrepublic.com/article/how-to-set-up-an-sftp-server-on-linux/

Steps to connect:

1. Establish tunnel from your laptop
gcloud compute start-iap-tunnel VM_NAME 22 --local-host-port=localhost:2222 --zone=us-central1-a (provide zone, where you have VM provisioned)

DamianS_1-1708367700556.png

 

2. Establish connection by doing sftp to localhost and provided port (screenshot taken from FileZilla

DamianS_2-1708367745357.png

3. sftp via CLI

DamianS_3-1708367797871.png

cheers,
DamianS

 

@ DamianS, thank you so much for putting all these efforts to help me out... recently very busy in some priority work so couldn't look into this issue and could not respond, but let me try and update you soon.

Thank you again!

TekXplorer

Hi @DamianS , I did tcp port forwarding for port 22 on private VM, then used the SFTP client to connect to the private VM using private IP & forwarded port, and that resolved the issue...

Thank you,

TekXplorer