sshfs mount remote folder linux and samba shared windows

using sshfs to mount another space linux and shared it to other windows os with samba

background problem
==================
we have big storage computer with linux debian os, lets say 192.168.0.77
and we have another ubuntu linux for manage service like ftp, samba etc, let say 192.168.0.81
the other computer have windows os, which will need the share storage

solution
==================

using sshfs for mounting storage from 192.168.1.77,
and using samba for shared it from 192.168.1.81

+- – -+                     +- – -+
| 77|                    | 81|                       +- – -+ +- – -+
|      |— sshfs —|      |— samba —| win win|
|      |                    |      |                       |  7   8  10 |
+- – -+                     +- – -+                       +- – -+ +- – -+
/mnt/backup        /home/user/backup    \\192.168.1.81\u2backup

how to

# user@ubuntu81:
# ==============
# create keygen for less password

ssh-keygen -t rsa

# root@debian77:
# ==============
# create new user ub for access folder for shared

useradd ub
passwd ub
su ub
mkdir ~/.ssh && cd ~/.ssh
scp user@ubuntu81:/home/user/.ssh/id_rsa.pub .
mv id_rsa.pub authorized_keys
exit

# create folder to shared
mkdir /mnt/backup
chown ub.ub /mnt/backup

# user@ubuntu81:
# ==============

# install sshfs
sudo apt-get install sshfs
sudo modprobe fuse
sudo adduser $USER fuse
sudo chown root:fuse /dev/fuse

# enable non root for mounting sshfs
sudo nano /etc/fuse.conf
# change
#user_allow_other
# to
user_allow_other
# save

# create folder to mount
mkdir ~/backup

# mounting remote folder
sshfs ub@debian77:/mnt/backup /home/user/backup -o allow_other

# check with write file and folder 
mkdir test-dir && touch test-file
ls -al

# do ls -al in root@debian77:/mnt/backup

# install samba
sudo apt-get install samba -y

# set password user for samba,
# you can set diferent password to login shell linux
sudo pdbedit -a user

# add new share in samba config
sudo nano /etc/samba/smb.conf
# add lines
[u2backup]
path = /home/user/backup
available = yes
valid users = user
read only = no
browseable = yes
public = yes
writable = yes

#save and restart samba
sudo /etc/init.d/samba restart

# now check from windows computer
# open explorer and type \\192.168.0.81\u2backup
# input user name and password samba
# and add some test file

sshfs-samba

Advertisements

Published by

G3n1k

just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s