可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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?
回答1:
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
first I downloaded and run the gcloud sdk : https://cloud.google.com/compute/docs/gcloud-compute/#install
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
I got the google_compute_engine private key from the .ssh/ folder and imported that into felizilla > settings > sftp
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
回答2:
At a high level, these are the steps:
- Install and run the gcloud SDK (
$ gcloud init
)
- Generate SSH key (
$ gcloud compute ssh
)
- Setup the FTP client (install and add the key file)
- Connect to the VM using the SFTP client
Assuming this question was asked here before this documentation from Google was available.
Also, I have recorded this, it might be helpful:
https://www.youtube.com/watch?v=9ssfE6ODpak
And just an FYI .. if the files that you need to transfer are pretty small in size then maybe you don’t need a SFTP client. Transfer directly from the console as seen here https://youtu.be/HEdXEEYOynE
回答3:
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.
回答4:
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.
回答5:
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
回答6:
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
回答7:
If I understand the question, you want have a SFTP in a instance with Debian.
Try this tutorial
Open the the port 22 in the firewall:
gcutil addfirewall port-22 --description="Open up port 22." --allowed="tcp:22"
Test with Filezilla Client establishing a SFTP connection.
Have Fun :)