Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to mount a directory on Google Compute Engine using sshfs

I am trying to mount a remote filesystem on Google Container Engine. I am following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh

Using following sshfs command:

sudo sshfs -o sshfs_debug,allow_other <instance-name>.<region>.<project_id>:/home/<user_name> /mnt/gce-container

I am getting error:

SSHFS version 2.5
read: Connection reset by peer

I referred this link https://cloud.google.com/sdk/gcloud/reference/compute/config-ssh and could login using ssh via following command:

$gcloud compute config-ssh
$ssh <instance-name>.<region>.<project_id>

Any ideas what might be going wrong here? I can't understand what keys and username should I use for sshfs login.

Update(11/5): I am using following command:

sshfs -o IdentityFile=~/.ssh/google_compute_engine <user>@<ip>:~/  /mnt/gce`

I have chowned /mnt/gce folder for my user. I checked the IP matches the entry in ~/.ssh/config file. However I still get the error read: Connection reset by peer

like image 934
Ajax Avatar asked May 02 '16 13:05

Ajax


People also ask

Can t SSH into GCP instance?

If gcloud CLI is out of date, you may be attempting to connect using a username that is not configured. To resolve this issue, update the gcloud CLI. You tried to connect to a Windows VM that doesn't have SSH enabled. To resolve this error, set the enable-windows-ssh key to TRUE in project or instance metadata.

How do I mount Google Drive in GCP?

Mounting your own Google Drive is fairly easy. Just import the drive tools and run the mount command. You will be asked to authenticate using a token that you create using Google Auth API. After you pasted the token your drive is mounted to the given path.

How do I enable SSH in GCP instance?

Connect through a browser from the GCP Marketplace Browse to the Google Cloud Platform console and sign in if required using your Google account. Find and select your project in the project list. Select the “Compute -> Compute Engine” menu item. Locate your server instance and select the SSH button.


1 Answers

The problem with command below is that

1) unless you have a static IP, it keeps changing on machine reboot

2) you need to use .pub file

sshfs -o IdentityFile=~/.ssh/google_compute_engine <user>@<ip>:~/  /mnt/gce

I finally got it working by following command:

sudo mkdir /mnt/gce
sudo chown <user> /mnt/gce

sshfs -o  IdentityFile=~/.ssh/google_compute_engine.pub <user_name>@<instance-name>.<region>.<project_id>:/home/<user_name> /mnt/gce
like image 110
Ajax Avatar answered Nov 15 '22 15:11

Ajax