短的:

短的:

我拼命想用 autofs 和 sshfs 自动挂载我的远程文件夹,但我无法让它工作。(我在 Fedora 16 下)

这有效:

sshfs [email protected]:/my/data /home/cx42net/data-distant -o uid=1000 -o gid=1000

因此,我定义了一个用于 ssh 的 RSA 密钥,尝试连接ssh,它无需输入密码即可工作。然后我再次尝试了上一个sshfs命令,它运行良好(耶!)

所以现在,我想使用autofs,这就是问题的开始:

我的 /etc/auto.master 文件的内容:

#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
/misc   /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
/net    -hosts
#
# Include /etc/auto.master.d/*.autofs
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as

# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master

/net    /etc/auto.sshfs    uid=1000,gid=1000,--timeout=30,--ghost

(1000:1000)是我的本地用户 uid/gid,而不是远程用户(我尝试获取的 SSH 文件夹)

我的 /etc/auto.sshfs:

data-distant    -fstype=fuse,port=22,rw,allow_other    :sshfs\#[email protected]\:/mnt/data/dev

当我启动 autofs 时,我得到的内容如下/var/log/messages

Oct 28 23:59:30 pc-maison autofs[3318]: Starting automount: [  OK  ]

一切似乎都很好。

但有时我会收到这样的消息:

Oct 28 23:41:01 pc-maison automount[2453]: create_udp_client: hostname lookup failed: Name or service not known
Oct 28 23:41:01 pc-maison automount[2453]: create_tcp_client: hostname lookup failed: Name or service not known
Oct 28 23:41:01 pc-maison automount[2453]: lookup_mount: exports lookup failed for data-distant

该文件夹/net/data-distant具有我的用户“cx42net”的权限(1000:1000)

我缺少什么才能使这个工作成功?

答案1

短的:

检查你的 sshfs 命令是否可以与 root 用户一起使用。

更长:

检查 root 用户是否设置了 ssh 身份密钥。通过 autofs 安装 sshfs 时,实际安装时需要 root 用户。

这仍然仅适用于单个用户使用这些支架的台式机或笔记本电脑用户!

自动主线

注意!使用您自己的 uid 和 gid 并指定您喜欢的挂载点,我使用 /auto/mehtod/address

/auto/sshfs /etc/auto.sshfs uid=1000,gid=1000,--timeout=60,--ghost

auto.sshfs 这比仅仅一个挂载更通用一点

#!/bin/bash

# Shell script that acccepts one argument, namely userid@server
# env >> /tmp/env_check
# whoami >> /tmp/env_check

key=$1
USER='your_local_user_used_for_ssh_identity_file'
REMOTEDEFAULT='default_to_this_user_otherwise_root'
key=${key//[: #]/}

# add user
[[ ! "$key" =~ "@" ]] && key="${REMOTEDEFAULT}@${key}"

case $key in
   ${REMOTEDEFAULT}@.Trash*)
      exit 1;;
   *)
      (
      echo "-fstype=fuse,idmap=user,rw,nodev,nonempty,transform_symlinks,noatime,allow_other,IdentityFile=/home/${USER}/.ssh/id_dsa,max_read=65536\\"
      echo -e "\t /uhome :sshfs\#$key\:\\"
      echo -e "\t /tmp :sshfs\#$key\:\/tmp\/\\"
      echo -e "\t /rootfs :sshfs\#$key\:\/")
esac

## this is a bit more complex. It creates subfolders to autofs-mount/remotename
## /uhome  = your remote homedirectory
## /rootfs = remote root '/'
## /tmp    = remote tmp # same as /roots/tmp

然后链接到您想要访问的文件夹 ln -s /auto/sshfs/[电子邮件保护]/uhome/ 远程主页

相关内容