2017年5月26日 星期五

linux samba 相關操作

最近 (20170513) WannaCry 勒索病毒搞的人心惶惶, smb protocol 似乎有什麼問題被拿來利用了, 不過還是紀錄一下 smb 相關用法。

mount samba filesystem in linux

# mkdir /mnt/cifs
# mount -t cifs //server-name/share-name /mnt/cifs -o username=shareuser,password=sharepassword,domain=nixcraft
# mount -t cifs //192.168.101.100/sales /mnt/cifs -o username=shareuser,password=sharepassword,domain=nixcraft
mount -t cifs //192.168.121.32/descent /mnt/cifs/  -o username=myname,password=mypwd

ref: http://www.cyberciti.biz/faq/linux-mount-cifs-windows-share/

samba access symbolic link
ref: http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?post_id=128058
edit smb.conf

follow symlinks = yes
unix extensions = no
wide links = yes


使用 smbclient copy smb server 檔案


ref: http://www.linuxso.com/command/smbclient.html
--user username%passwd, 此例子的密碼是空字串 ''

get <remote file name>[local file name]
Copy the file called remote file name from the server to the
machine running the client. If specified, name the local copy local
file name. Note that all transfers in smbclient are binary. See
also the lowercase command.

from samba server copy to local
$ smbclient -c "get e.iso /tmp/e.iso" \\\\127.0.0.1\\smb_test --user username%''

put<local file name> [remote file name]
Copy the file called local file name from the machine running the

client to the server. If specified, name the remote copy remote
file name. Note that all transfers in smbclient are binary. See
also the lowercase command.

from local copy to samba server copy
$ /usr/bin/smbclient -c "put /tmp/exam.d e.txt" //127.0.0.1/smb_test/ --user username%''

沒有留言:

張貼留言

使用 google 的 reCAPTCHA 驗證碼, 總算可以輕鬆留言了。

我實在受不了 spam 了, 又不想讓大家的眼睛花掉, 只好放棄匿名留言。這是沒辦法中的辦法了。留言的朋友需要有 google 帳號。