Home
Packages
Forums
Wiki
GitLab
Security
AUR
Download
コンテンツにスキップ
メインメニュー
メインメニュー
サイドバーに移動
非表示
案内
メインページ
目次
コミュニティに貢献
最近の出来事
おまかせ表示
特別ページ
交流
ヘルプ
貢献
最近の更新
最近の議論
新しいページ
統計
リクエスト
ArchWiki
検索
検索
表示
アカウント作成
ログイン
個人用ツール
アカウント作成
ログイン
SSHFSのソースを表示
ページ
議論
日本語
閲覧
ソースを閲覧
履歴を表示
ツール
ツール
サイドバーに移動
非表示
操作
閲覧
ソースを閲覧
履歴を表示
全般
リンク元
関連ページの更新状況
ページ情報
表示
サイドバーに移動
非表示
←
SSHFS
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
[[Category:ファイルシステム]] [[Category:Secure Shell]] [[en:Sshfs]] [[es:Sshfs]] [[it:Sshfs]] [[ru:Sshfs]] {{Related articles start}} {{Related|SSH}} {{Related articles end}} sshfs を使うことで ([[SSH]] でアクセスできる) リモートシステムをローカルフォルダにマウントすることができます。ツールを使ってマウントしたファイルを様々に操作することが可能です (コピー、名前を変更、vim で編集など)。基本的に shfs の代わりに sshfs を使うことが推奨されます。shfs の新しいバージョンは2004年からリリースされていません。 == インストール == [[公式リポジトリ]]から {{Pkg|sshfs}} を[[インストール]]してください。 === マウント === {{Tip|[[Google Authenticator]] を使うことで sshfs のセキュリティを向上させることができます。}} ディレクトリをマウントする前に、対象のディレクトリのファイルパーティションが正しく設定されているか (ユーザーがアクセスできるか) 確認してください。マウントするには、{{ic|sshfs}} を実行してリモートディレクトリをマウントします: $ sshfs ''USERNAME@HOSTNAME_OR_IP:/REMOTE_PATH LOCAL_MOUNT_POINT SSH_OPTIONS'' 例: $ sshfs sessy@mycomputer:/remote/path /local/path -C -p 9876 -o allow_other {{ic|-p 9876}} はポート番号、{{ic|-C}} は圧縮の使用、{{ic|-o allow_other}} は root 以外のユーザーの読み書きの許可です。 {{Note|-p スイッチを使うのが面倒な場合、{{ic|~/.ssh/config}} でホストごとに非標準ポートを定義することもできます。詳しくは [[Secure Shell#ssh の設定に接続データを保存する]] を参照。}} 必要であれば、SSH はパスワードを尋ねます。何度もパスワードを入力したくない場合は、次を読んでください: [http://linuxmafia.com/~karsten/Linux/FAQs/sshrsakey.html How to Use RSA Key Authentication with SSH] または [[SSH 鍵]]。 {{Tip|To quickly mount a remote dir, do some file-management and unmount it, put this in a script: sshfs USERNAME@HOSTNAME_OR_IP:/REMOTE_PATH LOCAL_MOUNT_POINT SSH_OPTIONS'' mc LOCAL_MOUNT_POINT fusermount -u LOCAL_MOUNT_POINT'' This will mount the remote directory, launch MC, and unmount it when you exit. }} === アンマウント === リモートシステムをアンマウントするには: $ fusermount -u ''LOCAL_MOUNT_POINT'' 例: $ fusermount -u /mnt/sessy == Chroot == (特定の) ユーザーをディレクトリに閉じ込めたい場合、{{ic|/etc/ssh/sshd_config}} を編集してください: {{hc|/etc/ssh/sshd_config|..... Match User someuser ChrootDirectory /chroot/%u ForceCommand internal-sftp #to restrict the user to sftp only AllowTcpForwarding no X11Forwarding no .....}} {{Note|chroot ディレクトリの所有者は root である必要があります。そうでない場合、接続ができません。詳しくは man ページで {{ic|Match, ChrootDirectory}} や {{ic|ForceCommand}} を確認してください。}} == ヘルパー == sshfs ファイルシステムを頻繁にマウントする必要がある場合、[[en2:sftpman|sftpman]] などの sshfs ヘルパーを使うと良いでしょう。 コマンドラインと GTK のフロントエンドが入っており、マウントやアンマウントをワンクリックで行うことができるようになります。 == 自動マウント == 起動時や、必要に応じて (ディレクトリのアクセス時に)、自動マウントを行うことができます。どちらにしても、セットアップは {{ic|/etc/[[fstab]]}} で行います。 {{Note|自動マウントは root ユーザーによって行われるため、h通常ユーザーの {{ic|.ssh/config}} で設定した Hosts は使えなくなります。root ユーザーで通常ユーザーの SSH 鍵を使うときは、{{ic|IdentityFile}} オプションにフルパスを指定してください。そして、ホストの署名が {{ic|.ssh/known_hosts}} ファイルに追加されるように root で一度は手動で sshfs マウントを使用します。}} === 必要に応じてマウント === {{ic|/etc/fstab}} エントリを使うことで systemd でオンデマンドのマウントを行えます。 例: user@host:/remote/folder /mount/point fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,IdentityFile=/home/user/.ssh/id_rsa,allow_other,reconnect 0 0 ここで重要なマウントオプションは ''noauto,x-systemd.automount,_netdev'' です。 * ''noauto'' で起動時にマウントしないように設定します。 * ''x-systemd.automount'' によって必要になったときにマウントします。 * ''_netdev'' はブロックデバイスではなくネットワークデバイスであることを指定します (''_netdev'' がないと "No such device" エラーが発生します)。 {{Tip| 別の方法が2つ存在します。どちらも新しいマウントポイントを追加するのに {{ic|/etc/fstab}} を編集する必要がなくなり、(autosshfs が有効になった) 通常ユーザーがアクセスしようとしただけで作成されます (例: {{ic|ls ~/mnt/ssh/[user@]yourremotehost[:port]}}): * {{AUR|autosshfs-git}} は AutoFS を使います。{{ic|autosshfs-user}} で使用するユーザーを有効にする必要があります。 * {{AUR|afuse}} は FUSE ファイルシステムによる多目的のユーザー空間自動マウントツールです。sshfs でも上手く動作します。ユーザーの有効化は必要ありません。実行例: {{ic|1=afuse -o mount_template='sshfs -o ServerAliveInterval=10 -o reconnect %r:/ %m' -o unmount_template='fusermount -u -z %m' ~/mnt/ssh}}。 }} === 起動時にマウント === {{ic|/etc/[[fstab]]}} で sshfs を使ってリモートのファイルシステムをマウントする例: USERNAME@HOSTNAME_OR_IP:/REMOTE/DIRECTORY /LOCAL/MOUNTPOINT fuse.sshfs defaults,_netdev 0 0 ''fstab'' の行の例: llib@192.168.1.200:/home/llib/FAH /media/FAH2 fuse.sshfs defaults,_netdev 0 0 ユーザーの SSH 鍵を使っている場合、自動的に動作するようになります。[[SSH 鍵]]を見て下さい。 複数のユーザーで sshfs を使いたい場合: user@domain.org:/home/user /media/user fuse.sshfs defaults,allow_other,_netdev 0 0 マウントする前にネットワークが有効になっていることを確認するために ''_netdev'' マウントオプションを設定することが重要です。 === ユーザーアクセスのセキュア化 === {{ic|/etc/[[fstab]]}} で自動マウントする場合、ファイルシステムは基本的に root によってマウントされます。デフォルトでは、通常ユーザーとしてアクセスして他のユーザーのアクセスを制限したいときに予期しない結果を招くことがあります。 マウントポイントの設定例: USERNAME@HOSTNAME_OR_IP:/REMOTE/DIRECTORY /LOCAL/MOUNTPOINT fuse.sshfs noauto,x-systemd.automount,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/USERNAME/.ssh/id_rsa,allow_other,default_permissions,uid=USER_ID_N,gid=USER_GID_N 0 0 オプションの説明: * ''allow_other'' - Allow other users than the mounter (i.e. root) to access the share. * ''default_permissions'' - Allow kernel to check permissions, i.e. use the actual permissions on the remote filesystem. This allows prohibiting access to everybody otherwise granted by ''allow_other''. * ''uid'', ''gid'' - set reported ownership of files to given values; ''uid'' is the numeric user ID of your user, ''gid'' is the numeric group ID of your user. == オプション == sshfs はローカル・リモートのユーザー ID を自動的に変換することができます。 Add the ''idmap'' option with ''user'' value to translate UID of connecting user: # sshfs -o idmap=user sessy@mycomputer:/home/sessy /mnt/sessy -C -p 9876 This will map UID of the remote user "sessy" to the local user, who runs this process ("root" in the above example) and GID remains unchanged. If you need more precise control over UID and GID translation, look at the options ''idmap=file'' and ''uidfile'' and ''gidfile''. == トラブルシューティング == === チェックリスト === Read the [https://wiki.archlinux.org/index.php/Secure_Shell#Checklist SSH Checklist] Wiki entry first. Further issues to check are: 1. Is your SSH login sending additional information from server's {{ic|/etc/issue}} file e.g.? This might confuse SSHFS. You should temporarily deactivate server's {{ic|/etc/issue}} file: $ mv /etc/issue /etc/issue.orig 2. Keep in mind that most SSH related troubleshooting articles you will find on the web are '''not''' Systemd related. Often {{ic|/etc/fstab}} definitions wrongly begin with {{ic|''sshfs#''user@host:/mnt/server/folder ... fuse ...}} instead of using the syntax {{ic|user@host:/mnt/server/folder ... fuse.''sshfs'' ... ''x-systemd'', ...}}. 3. Check that the owner of server's source folder and content is owned by the server's user. $ chown -R USER_S: /mnt/servers/folder 4. The server's user ID can be different from the client's one. Obviously both user names have to be the same. You just have to care for the client's user IDs. SSHFS will translate the UID for you with the following mount options: uid=''USER_C_ID'',gid=''GROUP_C_ID'' 5. Check that the client's target mount point (folder) is owned by the client user. This folder should have the same user ID as defined in SSHFS's mount options. $ chown -R USER_C: /mnt/client/folder 6. Check that the client's mount point (folder) is empty. By default you can't mount SSHFS folders to non-empty folders. 7. If you want to automount SSH shares by using an SSH public key authentication (no password) via {{ic|/etc/fstab}}, you can use this line as an example: ''USER_S''@''SERVER'':/mnt/on/server /nmt/on/client fuse.sshfs x-systemd.automount,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/''USER_C''/.ssh/id_rsa,allow_other,default_permissions,uid=''USER_C_ID'',gid=''GROUP_C_ID'',umask=0 0 0 Considering the following example settings ... SERVER = Server host name (serv) USER_S = Server user name (pete) USER_C = Client user name (pete) USER_S_ID = Server user ID (1004) USER_C_ID = Client user ID (1000) GROUP_C_ID = Client user's group ID (100) you get the client user's ID and group ID with $ id USERNAME this is the final SSHFS mount row in {{ic|/etc/fstab}}; pete@serv:/mnt/on/server /nmt/on/client fuse.sshfs x-systemd.automount,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/pete/.ssh/id_rsa,allow_other,default_permissions,uid=1004,gid=1000,umask=0 0 0 8. If you know another issue for this checklist please add it the list above. === ピアによって接続がリセットされる === * ホストネームを使ってリモートマシンにアクセスしようとしている場合、ドメイン名が解決できないのが原因かもしれないので、IP アドレスを使って接続してみてください。{{ic|/etc/hosts}} を編集してサーバーの設定が正しいことを確認してください。 * デフォルトではないキーの名前を使っている場合、{{ic|-i .ssh/my_key}} と指定しても意味がありません。{{ic|-o IdentityFile<nowiki>=</nowiki>/home/user/.ssh/my_key}} のようにキーのフルパスを使う必要があります。 * {{ic|sshfs_debug}} オプションを追加することで問題の解決に役に立つ情報が得られます ({{ic|sshfs -o sshfs_debug user@server ...}})。 * 何も有用な情報が得られないときは、{{ic|debug}} オプションも追加してみてください。 * sshfs で DD-WRT などが動作しているルーターに接続する場合、[http://www.dd-wrt.com/wiki/index.php/SFTP_with_DD-WRT こちら] に解決方法が載っています (dropbear にパッチをあてるかわりに sshfs コマンドで {{ic|1=-osftp_server=/opt/libexec/sftp-server}} オプションを使うこともできます)。 * 古いフォーラムスレッド: [https://bbs.archlinux.org/viewtopic.php?id=27613 sshfs: Connection reset by peer] * ユーザーを使ってサーバーにログインできることを確認してください (特に AllowUsers を使用する場合)。 * {{ic|/etc/ssh/sshd_config}} で {{ic|Subsystem sftp /usr/lib/ssh/sftp-server}} が有効になっていることを確認してください。 {{Note| When providing more than one option for sshfs, they must be comma separated. Like so: '{{ic|sshfs -o sshfs_debug,IdentityFile<nowiki>=</nowiki></path/to/key> user@server ...}}')}} === Remote host has disconnected === ''sshfs'' を使おうとした直後にこのメッセージが表示される場合: * まず'''リモート'''マシンに ''sftp'' がインストールされていることを確認してください。インストールしていないと、動作しません。 {{Tip|リモートサーバーで OpenWRT を動かしている場合: {{ic|opkg install openssh-sftp-server}} でインストールできます。}} * それから、リモートマシンの {{ic|/etc/ssh/sshd_config}} に記載されている {{ic|Subsystem}} のパスが正しいかどうか確認してください。パスは {{ic|find / -name sftp-server}} で確認できます。 Arch Linux では {{ic|/etc/ssh/sshd_config}} のデフォルト値は {{ic|Subsystem sftp /usr/lib/ssh/sftp-server}} です。 === Thunar と FAM のリモートファイルの問題 === リモートフォルダが表示されず、ホームディレクトリに戻ってしまう場合、あるいは Thunar で他のリモートファイルにアクセスできない場合、FAM を {{Pkg|gamin}} で置き換えてください。Gamin は FAM の後継です。 === アプリがフリーズする (例: Nautilus, Gedit) === {{Note|下記の設定をすると最近使用したファイルのリストが作られなくなります。また、書き込みエラーが発生することがあります。}} アプリケーションがフリーズする (反応しなくなる) 場合、{{ic|~/recently-used.xbel}} の書き込み権限を無効化する必要があるかもしれません: # chattr +i /home/USERNAME/.local/share/recently-used.xbel 詳しくは次の [https://bugs.archlinux.org/task/40260 バグレポート] を見て下さい。 === sshfs をマウントされているときにシャットダウンでフリーズ === sshfs を手動でマウントして、シャットダウン前にアンマウントしていなかった場合、systemd がシャットダウン時にフリーズすることがあります。この問題を解決するには、以下のファイルを (root で) 作成してください: {{hc|/etc/systemd/system/killsshfs.service|<nowiki> [Unit] After=network.target [Service] RemainAfterExit=yes ExecStart=-/bin/true ExecStop=-/usr/bin/pkill sshfs [Install] WantedBy=multi-user.target </nowiki>}} そしてサービスを有効化します: {{ic|systemctl enable killsshfs.service}} == 参照 == * [http://wiki.gilug.org/index.php/How_to_mount_SFTP_accesses How to mount chrooted SSH filesystem], with special care with owners and permissions questions.
このページで使用されているテンプレート:
テンプレート:AUR
(
ソースを閲覧
)
テンプレート:Broken package link
(
ソースを閲覧
)
テンプレート:Hc
(
ソースを閲覧
)
テンプレート:Ic
(
ソースを閲覧
)
テンプレート:META Related articles start
(
ソースを閲覧
)
テンプレート:Note
(
ソースを閲覧
)
テンプレート:Pkg
(
ソースを閲覧
)
テンプレート:Related
(
ソースを閲覧
)
テンプレート:Related articles end
(
ソースを閲覧
)
テンプレート:Related articles start
(
ソースを閲覧
)
テンプレート:Tip
(
ソースを閲覧
)
SSHFS
に戻る。
検索
検索
SSHFSのソースを表示
話題を追加