CentOS Stream 10
Sponsored Link

OpenSSH : SSHFS を利用する2024/12/19

 

SSHFS (SSH Filesystem) を利用すると、SSH 接続で他ホストのファイルシステムをマウントすることができます。

[1] fuse-sshfs をインストールします。
# EPEL からインストール

[root@dlp ~]#
dnf --enablerepo=epel -y install fuse fuse-sshfs
[2] 任意の一般ユーザーで実行可能です。
例として、[cent] ユーザーで、[node01.srv.world] 上の [/home/cent/work] をマウントします。
# 任意のマウント用ディレクトリ作成

[cent@dlp ~]$
mkdir ~/sshmnt
# SSHFS でマウント

[cent@dlp ~]$
sshfs node01.srv.world:/home/cent/work ~/sshmnt

Enter passphrase for key '/home/cent/.ssh/id_ed25519':
[cent@dlp ~]$
df -hT

Filesystem                       Type        Size  Used Avail Use% Mounted on
/dev/mapper/cs-root              xfs          26G  2.5G   24G  10% /
devtmpfs                         devtmpfs    4.0M     0  4.0M   0% /dev
tmpfs                            tmpfs       2.0G     0  2.0G   0% /dev/shm
tmpfs                            tmpfs       782M  8.6M  773M   2% /run
tmpfs                            tmpfs       1.0M     0  1.0M   0% /run/credentials/systemd-journald.service
/dev/vda2                        xfs         960M  278M  683M  29% /boot
tmpfs                            tmpfs       1.0M     0  1.0M   0% /run/credentials/serial-getty@ttyS0.service
tmpfs                            tmpfs       1.0M     0  1.0M   0% /run/credentials/getty@tty1.service
tmpfs                            tmpfs       391M   12K  391M   1% /run/user/0
node01.srv.world:/home/cent/work fuse.sshfs   26G  2.4G   24G   9% /home/cent/sshmnt
# マウントされた

# アンマウントする場合は以下
# [umount] コマンドでも可

[cent@dlp ~]$
fusermount -u ~/sshmnt
関連コンテンツ