1. SmbClient
Try with the smbclient on that server
> smbclient //localhost/sillycat-nas -b 8192 -c "put README.md" -U sillycat
Enter sillycat's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.6]
putting file README.md as \README.md (0.6 kb/s) (average 0.6 kb/s)
But I fail to connect that from outside the internal network. I will try forwarding other ports later.
135,137-139, and 445
It seems that samba solution is not secure. I will check other solution.
Remote samba and I will cut the forwarding later.
> sudo apt-get remove samba
2. FTP/SFTP Solution
SFTP
Create the new user
> sudo useradd kiko -m -G users
> sudo useradd kangping -m -G users
> sudo useradd xieqiuyuan -m -G users
> sudo passwd kiko
> sudo passwd kangping
> sudo passwd xieqiuyuan
Mapping the disk to the new user
> sudo ln -s /opt/disk1/share /home/sillycat/home-nas
Then we can use some other SFTP client to directly connect to server from SSH port.
FileZilla and other things. But it seems that we can not limit the user to its own directory.
FTP
http://mina.apache.org/ftpserver-project/
Download the latest version
> wget http://apache.mirrors.lucidnetworks.net/mina/ftpserver/1.0.6/dist/ftpserver-1.0.6.tar.gz
Unzip and place in the working directory
Command to run
> bin/ftpd.sh res/conf/ftpd-typical.xml
Prepare the directory
> sudo ln -s /opt/disk1/users/sillycat /opt/ftpserver/res/home/sillycat/sillycat
I login the system with these command
ftp localhost 2121
Connected to localhost.
220 Service ready for new user.
Name (localhost:carl): sillycat
331 User name okay, need password for sillycat.
Password:
230 User logged in, proceed.
Remote system type is UNIX.
ftp>
Upload the file
ftp> put README.md
local: README.md remote: README.md
200 Command PORT okay.
150 File status okay; about to open data connection.
226 Transfer complete.
List the file
ftp> ls -l
200 Command PORT okay.
150 File status okay; about to open data connection.
-rw------- 1 user group 0 Nov 5 22:52 111.txt
-rw------- 1 user group 147 Nov 5 22:54 README.md
226 Closing data connection.
delete the file
ftp> mdelete 111.txt
mdelete 111.txt? y
250 Requested file action okay, deleted /111.txt.
3. Passive and Active in FTP
My just use very simple configuration in the ftp server, but it seems that I have some problem on connect to it. So I come back and search what are the details in FTP protocol.
There are 2 Types of Data Transfers - Active (PORT) and Passive(PASV)
The client problem can specify active mode by sending the “PORT” command to instruct that the server should connect back to a specified IP address and port number and then send the data.
A client program can choose passive mode by using the “PASV” command to ask that the server tell the client an IP address and port number that the client can connect to and receive the data.
http://www.ncftp.com/ncftpd/doc/misc/ftp_and_firewalls.html
Active FTP :
command : client >1023 -> server 21
data : client >1023 <- server 20
Passive FTP :
command : client >1023 -> server 21
data : client >1024 -> server >1023
Command passive will on/off the mode
I will change to use passive mode and I will also have the settings as follow:
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
And I am using FileZilla on MAC and FTPManager on iOS.
References:
Previous Blog
http://sillycat.iyunv.com/blog/2254550
Mac OS to samba
http://users.wfu.edu/yipcw/atg/apple/smb/
Remaining Rsync work
http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/
http://www.makeuseof.com/tag/turn-your-raspberry-pi-into-a-nas-box/
SFTP and Clients
https://cyberduck.io/
https://filezilla-project.org/