1. 程式人生 > 實用技巧 >網路檔案共享集合-SSH、SAMBA、NFS

網路檔案共享集合-SSH、SAMBA、NFS

UBUNTU

ssh

1)安裝:apt-get install openssh-server
2)配置:vim /etc/ssh/sshd_config
-> 注 釋 PermitRootLogin without-password,新增PermitRootLogin yes

samba

1)安裝:apt-get install samba samba-common
2)配置:cp /etc/samba/smb.conf /etc/samba/smb.conf.bak && vim /etc/samba/smb.conf
-> 在 max log size = 1000 下面新增 security = user


-> 在檔案末尾新增:

    [myshare] 
    comment = my share 
    path = /home/xxx/share 
    browseable = yes
    writable = yes

3)新增使用者:smbpasswd -a [user]
4)啟動:service smbd restart && service nmbd restart
5)建立路徑:mkdir ~/share

nfs

1)安裝服務:apt-get install nfs-common nfs-kernel-server
2)建立共享目錄:mkdir /nfs


3)配置共享目錄:vi /etc/exports
->在檔案末尾增加如下內容:
/nfs *(rw,sync,no_root_squash,no_subtree_check)
4)重啟服務:

service rpcbind restart && service nfs-kernel-server restart
showmount -e

5)測試掛載本機:

mkdir /mnt/nfs && touch /nfs/test.c
mount -t nfs 192.168.122.183:/nfs /mnt/nfs
ls /mnt/nfs 

PC

ssh

1)開啟MobaXterm

》會話》新會話》SHH》遠端主機》ok
2)輸入賬戶和密碼

samba

1)資源管理器路徑 \\192.168.x.x

nfs

1)Win右鍵 》網路連線》更改介面卡選項
2)檢視虛擬機器網絡卡IP:VMnet8右鍵》屬性》IPV4雙擊》
3)開發板網口連線電腦,設定乙太網IP:乙太網右鍵》屬性》IPV4雙擊》使用下面IP地址》確定
-> 如虛擬機器網絡卡IP為192.168.122.1
-> 則乙太網IP設定為192.168.122.122/255.255.255.0/192.168.122.1
4) Ctrl選擇VMnet8和乙太網 右鍵》橋接
5)開發板串列埠連線電腦,設定開發板IP:
-> 命令列輸入:ifconfig eth0 192.168.122.123 netmask 255.0.0.0 up

6)掛載命令:mount -t nfs -o nolock 192.168.122.183:/home/long/nfs nfs