티스토리 뷰

SSHFS는 서버나 워크스테이션에 위치한 디렉토리와 파일을 SSH 연결을 통해 클라이언트가 마운트하고 통신할 수 

있게 하는 파일 시스템이다.

SSHFS는 SFTP를 사용하기 때문에 서버와 클라이언트 간에 전송된 모든 데이터를 암호화하고 암호를 해독해야 하며, 

이로 인해 NFS에 비해 성능이 약간 저하되고 클라이언트 및 서버의 CPU 사용량이 증가한다.

 

1. SSHFS 설치

# UBUNTU
apt install sshfs

# RedHat기반의 Linux
yum install sshfs

# Mac
brew cask install osxfuse
brew install sshfs

# Windows
WinFsp, SSHFS-WIN 두개의 패키지 설치

 

2. 원격 파일 시스템 마운트

sshfs [user@]host:[remote_directory] mountpoint [options]

2-1 마운트 디렉토리 생성 및 원격디렉토리 연동

# 마운트 디렉토리생성
mkdir /temp

# 원격 디렉토리 연동
sshfs demo@192.168.10.121:/twins/temp /temp

마운트시 사용자의 비밀번호를 입력하라고 나오면 암호를 입력 하면 된다.

만약 디렉터리를 마운트 할 때마다 암호를 입력하지 않으려면  SSH키를 생성하고 암호없는 SSH로그인을 설정하면 된다.

생활코딩 참조 : SSH Key - 비밀번호 없이 로그인 - 원격제어 (opentutorials.org) 

 

SSH Key - 비밀번호 없이 로그인 - 원격제어

SSH Key란? 서버에 접속 할 때 비밀번호 대신 key를 제출하는 방식이다.  SSH Key는 언제 사용하는가? 비밀번호 보다 높은 수준의 보안을 필요로 할 때 로그인 없이 자동으로 서버에 접속 할 때 SSH Key

opentutorials.org

2.2 SSH public key 생성

$ local@local-server: ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:MY6jr5SfPzF1e9AE30rZYD3RaxzKov+718ErVeaUwdQ root@daniel-server
The key's randomart image is:
+---[RSA 3072]----+
|            ..=++|
|             o.XE|
|        o   .o* O|
|       o o..o+.*+|
|      o S....o++.|
|     o .o.  . .+.|
|    +    o.  .. +|
|   . o ..  . . o.|
|    ..+...  .+=  |
+----[SHA256]-----+

$ local@local-server: ls ~/.ssh/
authorized_keys  id_rsa  id_rsa.pub

2.3  원격서버에 public key 등록

# 원격 서버에 public key 등록
$ local@local-server: scp id_rsa.pub 192.168.10.121:/root/.ssh/authorized_keys
root@116.120.58.20's password:
id_rsa.pub                    100%  568   515.0KB/s   00:00

$ local@local-server: ssh 192.168.10.121
$ demo@demo-server:

 

 

3. 원격 디렉토리 마운트

$ vi /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/2598aa44-fcd1-4245-abe2-921684e27dbb / ext4 defaults 0 1
/swap.img       none    swap    sw      0       0
demo@192.168.10.121:/twins/temp /temp  fuse.sshfs  defaults,IdentityFile=/home/twins/.ssh/id_rsa,_netdev,delay_connect,allow_other,uid=1000,gid=1000    0     0

:wq

$ mount --all

 

4. 마운트 해제

unmout /temp

 

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함