SFTP into Google Compute Engine

2019-01-14 04:16发布

I have been playing around with Debian on Compute Engine and was wondering how I could SFTP into the server. I can't find any documentation on it and was hoping someone could point me in the right direction.

Thanks!

If this isn't possible, is the best way to manage static sites through SCP?

7条回答
Emotional °昔
2楼-- · 2019-01-14 04:47

I gave up with gcloud compute copy-files as I couldn't figure out why my instance was not been fetch and something with insufficient permissions, then I started looking into how to sftp into my gcloud instance

this is how I got this to work with filezilla

  1. first I downloaded and run the gcloud sdk : https://cloud.google.com/compute/docs/gcloud-compute/#install

  2. when I first try to connect to an instance from my terminal I was prompted to to create ssh keys, I'm on a mac so the keys were setup in /Users// folder under .ssh/ folder

  3. I got the google_compute_engine private key from the .ssh/ folder and imported that into felizilla > settings > sftp

  4. the host is the ip address of my gcloud vm instance, the user is whatever your username is once you connect to the instance via ssh.. check the prompt: [@]$, your key should be your method of authentication. your remote directory is the same as /home//, server type is unix (I had centos vm in google cloud)

Once my files were uploaded into my directory on my instance from my computer I was able to mv them to wherever I needed those files to be within the gcloud vm instance.

I was again a happy camper.

sources: http://winscp.net/eng/docs/guide_google_compute_engine

查看更多
甜甜的少女心
3楼-- · 2019-01-14 04:49

ssh, scp and sftp should all work if you specify the instance's IP address. You can use DNS for this if you have a static IP address, or you can use the IP address from gcutil listinstances or the console.

Once you know the IP address of the instance, you'll also need your ssh private key, which is usually at ~/.ssh/google_compute_engine. Then you can connect via sftp as follows:

sftp -o IdentityFile ~/.ssh/google_compute_engine user@host
查看更多
手持菜刀,她持情操
4楼-- · 2019-01-14 04:52

If I understand the question, you want have a SFTP in a instance with Debian.

  1. Try this tutorial

  2. Open the the port 22 in the firewall:

    gcutil addfirewall port-22 --description="Open up port 22." --allowed="tcp:22"

  3. Test with Filezilla Client establishing a SFTP connection.

Have Fun :)

查看更多
萌系小妹纸
5楼-- · 2019-01-14 04:57

On a Mac or linux OS, use the "gcloud compute config-ssh: command. This will setup the conf file in you .ssh dir and allow you to use ssh, scp & sftp using the alias that is configured in the config file.

gcloud doc for config-ssh https://cloud.google.com/sdk/gcloud/reference/compute/config-ssh

查看更多
再贱就再见
6楼-- · 2019-01-14 04:58

You can upload and download files with gcloud compute copy-files, e.g., upload via:

gcloud compute copy-files \
     ~/local-dir/file-1 \
     my-instance:~/remote-destination \
     --zone us-central1-a

and download via:

gcloud compute copy-files \
     my-instance:~/file-1 \
     my-instance:~/file-2 \
     ~/local-dir \
     --zone us-central1-a

The gcloud tool is included in the Google Cloud SDK and comes preinstalled in standard Google Compute Engine VM images.

查看更多
小情绪 Triste *
7楼-- · 2019-01-14 05:04

Seem that google computer engine already has SFTP service by default. Following is an excellent step by step instruction using WinSCP as SFTP client to connect to the service. It works perfectly for me on first try.

http://winscp.net/eng/docs/guide_google_compute_engine

Same principle should applies using other FTP client software. Hope will save someone time and effort.

查看更多
登录 后发表回答