无法使用 sshfs 在 Google Compute Engine 上挂载目录
Unable to mount a directory on Google Compute Engine using sshfs
我正在尝试在 Google 容器引擎上安装远程文件系统。我正在学习本教程:https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh
使用以下 sshfs 命令:
sudo sshfs -o sshfs_debug,allow_other <instance-name>.<region>.<project_id>:/home/<user_name> /mnt/gce-container
我遇到错误:
SSHFS version 2.5
read: Connection reset by peer
我提到了这个 link https://cloud.google.com/sdk/gcloud/reference/compute/config-ssh
并可以通过以下命令使用 ssh 登录:
$gcloud compute config-ssh
$ssh <instance-name>.<region>.<project_id>
知道这里可能出了什么问题吗?我不明白应该使用什么密钥和用户名进行 sshfs 登录。
更新(11/5):
我正在使用以下命令:
sshfs -o IdentityFile=~/.ssh/google_compute_engine <user>@<ip>:~/ /mnt/gce`
我已经为我的用户创建了 /mnt/gce 文件夹。我检查了 IP 是否与 ~/.ssh/config 文件中的条目匹配。但是我仍然收到错误 read: Connection reset by peer
一些可能导致问题的原因:
- 不要以 root 身份使用 sshfs。它是一个 FUSE 文件系统,用于用户挂载。
- 不要指定完整路径作为远程文件系统。因为是SSH,所以默认情况下,远程端的$PWD就是登录用户的$HOME。
如果 ssh 工作,sshfs 也将工作。最简单的方法是确保 ~/.ssh/config 有一个远程主机条目,其中提供了用户、端口等。
下面命令的问题是
1) 除非你有静态 IP,否则它会在机器重启时不断变化
2) 您需要使用 .pub 文件
sshfs -o IdentityFile=~/.ssh/google_compute_engine <user>@<ip>:~/ /mnt/gce
我终于通过以下命令让它工作了:
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
如果你从 sshfs 得到这个
read: Connection reset by peer
可能有助于将文件设置为只读
chmod 400 /{{path_to_your_key}}/keypair.pem
然后重新连接。
我正在尝试在 Google 容器引擎上安装远程文件系统。我正在学习本教程:https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh
使用以下 sshfs 命令:
sudo sshfs -o sshfs_debug,allow_other <instance-name>.<region>.<project_id>:/home/<user_name> /mnt/gce-container
我遇到错误:
SSHFS version 2.5
read: Connection reset by peer
我提到了这个 link https://cloud.google.com/sdk/gcloud/reference/compute/config-ssh 并可以通过以下命令使用 ssh 登录:
$gcloud compute config-ssh
$ssh <instance-name>.<region>.<project_id>
知道这里可能出了什么问题吗?我不明白应该使用什么密钥和用户名进行 sshfs 登录。
更新(11/5): 我正在使用以下命令:
sshfs -o IdentityFile=~/.ssh/google_compute_engine <user>@<ip>:~/ /mnt/gce`
我已经为我的用户创建了 /mnt/gce 文件夹。我检查了 IP 是否与 ~/.ssh/config 文件中的条目匹配。但是我仍然收到错误 read: Connection reset by peer
一些可能导致问题的原因:
- 不要以 root 身份使用 sshfs。它是一个 FUSE 文件系统,用于用户挂载。
- 不要指定完整路径作为远程文件系统。因为是SSH,所以默认情况下,远程端的$PWD就是登录用户的$HOME。
如果 ssh 工作,sshfs 也将工作。最简单的方法是确保 ~/.ssh/config 有一个远程主机条目,其中提供了用户、端口等。
下面命令的问题是
1) 除非你有静态 IP,否则它会在机器重启时不断变化
2) 您需要使用 .pub 文件
sshfs -o IdentityFile=~/.ssh/google_compute_engine <user>@<ip>:~/ /mnt/gce
我终于通过以下命令让它工作了:
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
如果你从 sshfs 得到这个
read: Connection reset by peer
可能有助于将文件设置为只读
chmod 400 /{{path_to_your_key}}/keypair.pem
然后重新连接。