我有一个我无法找到答案的问题。我有两台计算机,都运行 Ubuntu Linux 12.04。我已经设置了我的第一台计算机(“家”),以便能够使用公共/私有 RSA 密钥身份验证通过 SSH 连接到我的第二台计算机(“远程”)。
这不是第一个在我的家用计算机上使用密钥身份验证建立的 SSH 连接,因此我的家用计算机有几个 id_rsa 私钥文件(每个文件都用于不同的计算机以进行 SSH 连接)。因此,我能够成功SSH只有当我指定(在密钥文件ssh,该-i选项),使用ssh username@ipaddress -i path/to/keyfile/id_rsa.2。
这很好用。但是,我也想使用sshfs挂载远程文件系统的 。虽然ssh使用多个密钥似乎很好,但我找不到sshfs使用正确私钥(“id_rsa.2”)的方法。
有没有办法sshfs做到这一点?
我有几个通过sshfs挂载的目录。我有时会与服务器断开连接(我无法配置)。我通常像这样挂载目录
sshfs user@server.example.com:/home/user /mnt/example
Run Code Online (Sandbox Code Playgroud)
当服务器断开连接时,sshfs 子系统不会卸载/释放目录,而是将其锁定为不可访问。键入时,安装仍然可见mount。当我打字
ls /mnt/example
Run Code Online (Sandbox Code Playgroud)
进程被锁定(Ctrl+c也无济于事)。我因此做
sudo umount -l /mnt/example
# find pid of corresponding process:
ps aux | grep example.com
kill -9 <pid of locked sshfs process>
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来处理这个问题?显然sshfs应该执行卸载和清理......理想情况下它会自动重新连接。
我正在使用sshfs通过 ssh 将带有一些 python 项目的文件夹挂载到我的~/目录中。
$ mkdir -p ~/mount/my-projects
$ sshfs user@example.com:/home/user/my-projects ~/mount/my-projects
Run Code Online (Sandbox Code Playgroud)
我可以按预期执行大多数命令:
$ ls ~/mount/my-projects
some-python-project
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试对 做任何事情sudo,它会因权限被拒绝而失败:
$ sudo ls ~/mount/my-projects
ls: cannot access /home/user/mount/my-projects: Permission denied
Run Code Online (Sandbox Code Playgroud)
我真正想要完成的是在我的本地机器上测试 python 包安装脚本:
$ cd ~/mount/my-projects/some-python-project
$ sudo python setup.py install
Run Code Online (Sandbox Code Playgroud) 我正在使用保险丝/sshfs 安装,到目前为止工作正常。现在我不得不重新安装服务器系统并突然出现经典read: Connection reset by peer错误。我正在使用公钥身份验证并将我的密钥复制到新安装的系统。正常的 ssh 登录工作正常。我将日志更改为调试,但遗憾的是这并没有给我任何有用的信息:
sshd[2077]: debug1: Forked child 2198.
sshd[2198]: Set /proc/self/oom_score_adj to 0
sshd[2198]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
sshd[2198]: debug1: inetd sockets after dupping: 3, 3
sshd[2198]: Connection from 192.168.1.6 port 47991
sshd[2198]: debug1: Client protocol version 2.0; client software version OpenSSH_6.1p1 Debian-4
sshd[2198]: debug1: match: OpenSSH_6.1p1 Debian-4 pat OpenSSH*
sshd[2198]: debug1: Enabling compatibility mode for protocol 2.0
sshd[2198]: debug1: Local version string SSH-2.0-OpenSSH_6.1p1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下行在 /etc/fstab 中输入 sshfs 安装:
sshfs#oli@192.168.0.2:/media/usb0 /media/ExtHD fuse defaults,nonempty,allow_other 0 0
Run Code Online (Sandbox Code Playgroud)
以便在启动时安装此卷。启动后,什么也没发生,但是当我使用命令 sudo mount -a 时,总是提示我输入密码。我已经设置了 SSH Keys 并将它们传输到 192.168.0.2 的计算机上,并且可以在没有密码的情况下登录到常规 ssh。如何阻止保险丝询问我的密码,以便在启动时自动安装卷?
如果它有帮助,我正在尝试从运行 Arch Linux 的笔记本电脑连接到运行 Debian 的家庭服务器。谢谢
我的/etc/fuse.conf文件中有以下内容:
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000
# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用选项挂载远程路径时allow_other:
> sshfs name@server:/remote/path /local/path -o allow_other
Run Code Online (Sandbox Code Playgroud)
我得到:
fusermount: failed to open /etc/fuse.conf: Permission denied
fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf
Run Code Online (Sandbox Code Playgroud)
正如我上面复制的那样,我已经三重检查了该选项user_allow_other在我的fuse.conf.
我也执行了sudo adduser my_user_name fuse(虽然不确定是否需要这样做),但我仍然遇到同样的问题。
为什么不能/etc/fuse.conf …
我的 fstab 中有这一行:
sshfs#ecarroll@o99:/opt/dealermade/ftp/inc /opt/dealermade/ftp/inc fuse defaults,idmap=user,users 0 0
Run Code Online (Sandbox Code Playgroud)
无论出于何种原因它都不起作用 - 没关系。如何让它不停止启动顺序。它提示我点击S跳过或M手动修复。如果它不是启动卷,我只希望我的卷挂载失败,而只是日志中的一个条目。
我正在使用sshfs以下方法创建一个小型备份脚本:
sshfs backup_user@target_ip:/home /mnt/backup
Run Code Online (Sandbox Code Playgroud)
有没有办法在这个命令中包含密码?
或者是否有另一种文件传输解决方案,可以包含除 FTP/SFTP 之外的登录密码?
有谁知道如何通过 SSHFS 挂载远程 SFTP 路径,以便您可以使用符号链接?当我这样做时,我创建的所有符号链接都指向错误的文件(不是我链接到的文件)。我感兴趣的所有符号链接都是相对的(不是绝对的),因此让它们看起来与远程机器上的完全一样是理想的。
使用带有默认挂载选项的 sshfs,我无法创建指向当前目录中另一个文件的符号链接:
$ cd /mnt/path/to/sshfs/mount
$ ln -s ./test ./test2
$ ls test2
lrwxrwxrwx 1 root webusers 11 Jul 3 09:11 test2 -> /test
Run Code Online (Sandbox Code Playgroud)
这显然是不正确的,因为链接目标在当前目录 ( ./test) 中,但在这里您可以看到 sshfs 创建了一个/test不正确的链接 - 链接目标/mnt/path/to/sshfs/mount/test不是/test.
通过transform_symlinks在挂载 sshfs 文件系统时添加该选项,我使用相同的命令获得了一个相对链接,但它仍然指向错误的位置:
$ cd /mnt/path/to/sshfs/mount
$ ln -s ./test ./test2
$ ls test2
lrwxrwxrwx 1 root webusers 11 Jul 3 09:13 test2 -> ../../../test
Run Code Online (Sandbox Code Playgroud)
在这里,我试图链接到./test当前目录,但我得到了一个指向../../../test三个级别的链接!
但是,使用命令行 SFTP 客户端连接sftp …