OS

2022.02.16 15:39

SSHFS : SSH를 이용하여 원격 서버 mount

  • 비아웹 오래 전 2022.02.16 15:39 인기
  • 4,342
    0

ssh 를 이용하여 remote 서버의 특정 폴더를 마운트하는 sshfs 에 대해 정리합니다.

 

0. 테스트 전제 조건

해당 서버 2대간의 ssh 접속 허용(iptables /firewall 허용 처리 필요)

 

1. 테스트 환경

OS : CentOS Linux release 7.9.2009 (Core)

sshfs master IP : 192.168.80.128

sshfs client IP : 192.168.80.129

 

2. 프로그램 설치

- sshfs 의 경우 client 서버에서만 프로그램 설치가 필요합니다.

# yum install epel-release # yum install sshfs

3. sshfs 를 사용하여 디스크 마운트

- 폴더 생성 절차는 생략합니다.

# sshfs root@서버IP:/sshfs /sshfs-mount
4. 접속 종료시 reconnect 옵션
# sshfs -o reconnect,nonempty root@서버_IP:/sshfs /sshfs-mount

 

5. allow_other : 마운트된 폴더에 일반 유저의 접근 허용

# sshfs -o reconnect,nonempty,allow_other root@서버_IP:/sshfs /sshfs-mount

sshfs 를 이용하여 mount 후 다른 사용자로 해당 폴더에 대해 permission deny

allow_other 옵션 사용시 다른 유저가 해당 폴더에 대한 access 가능

- 일반 사용자에서 파일 생성시 소유자 및 그룹이 root 로 나타남

 

6. 키 파일을 이용한 sshfs 로그인

IdentityFile="키파일 path"

# sshfs -o reconnect,nonempty,allow_other,IdentityFile=/root/.ssh/id_rsa root@서버_IP:/sshfs /sshfs-mount

 

 

cf. Transport endpoint is not connected 해결 방법

[root@client /]# sshfs -o reconnect,nonempty root@서버_IP:/sshfs /sshfs-mount fuse: bad mount point `/sshfs-mount': Transport endpoint is not connected
# fusermount -u /sshfs-mount

감사합니다.

서버호스팅 비아웹

  • 공유링크 복사