`
sillycat
  • 浏览: 2560286 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Build Home NAS(2)SmbClient SFTP FTP

 
阅读更多
Build Home NAS(2)SmbClient SFTP FTP

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

> sudo ln -s /opt/disk1/share /opt/ftpserver/res/home/sillycat/share

FTP Command Line
> sudo apt-get install ftp

> ftp localhost 2121

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

  "
id="nasServer"
        max-logins="20"
        anon-enabled="false"
        max-login-failures="3"
        login-failure-delay="500">
<listeners>
<nio-listener name="default" port="2121" local-address="192.168.0.198">

    <ssl>

                <keystore file="./res/ftpserver.jks" password="password" />
                    </ssl>
                    <data-connection idle-timeout="60">
                      <active enabled="false" local-address="192.168.0.198" local-port="2020" ip-check="true" />
                      <passive ports="2023-2043" address="192.168.0.198" external-address="sillycat.ddns.net" />
          </data-connection>

</nio-listener>

</listeners>
<file-user-manager file="./res/conf/users.properties" encrypt-passwords="false"/>
</server>

We can also adjust the logging here
/opt/ftpserver/common/classes

cat log4j.properties

log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=./res/log/ftpd.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[%5p] %d [%X{userName}] [%X{remoteIp}] %m%n

And I am using FileZilla on MAC and FTPManager on iOS.

References:
Previous Blog
http://sillycat.iteye.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/

FTP
http://sillycat.iteye.com/blog/562426
http://sillycat.iteye.com/blog/562428

http://sillycat.iteye.com/blog/563904

http://sillycat.iteye.com/blog/563906
http://sillycat.iteye.com/blog/563908
http://sillycat.iteye.com/blog/563909
分享到:
评论

相关推荐

    sclo-php73-php-smbclient-1.0.0-2.el7.x86_64.rpm

    官方离线安装包,亲测可用

    04Linux网络服务FTP文件传输服务v10.pptx

    "Linux网络服务FTP文件传输服务" FTP(File Transfer Protocol)是一种常用的文件传输协议,允许用户在网络上传输文件。FTP服务是一种基于客户端/服务器架构的服务,客户端发出请求,服务器响应请求并提供文件传输...

    FTP、SMB方式下载、删除远程服务器文件

    FTP(File Transfer Protocol)和SMB(Server Message Block)是两种常见的网络文件共享协议,用于在客户端和服务器之间传输文件。本文将详细讲解这两种协议的工作原理、特点以及如何使用它们来下载和删除远程服务器...

    sclo-php72-php-smbclient-1.0.0-1.el7.x86_64.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    jcifs-1.3.18 用于android访问samba服务器。支持匿名访问,实现smbclient -L列出服务器用户名

    下载jar后,把jcifs-1.3.18.3.jar放在代码build.gradle同级新建的文件夹libs中。工程的app.build.gradle里面加上包的导入: implementation files('libs/jcifs-1.3.18.3.jar') 资源里面有参考代码。

    libsmbclient-php:smbclient对PHP的扩展

    pecl install smbclient 二进制软件包安装 一些发行版提供了二进制软件包: Fedora / RHEL / CentOS的RPM: Debian的DEB: 适用于Ubuntu的DEB: 从源安装 通过软件包libsmbclient-dev(Debian / Ubuntu)或...

    虚拟机LINUX与主机WINDOWS文件共享

    执行 smbclient 命令成功后,进入 smbclient 环境,可以执行和 ftp 命令中相似的命令:cd, lcd, get, mget, put, mput 等。 在 WINDOWS 机子上访问 LINUX 资源需要使用两个进程:nmbd 和 smbd。nmbd 是提供 WINDOWS...

    smbclientmap:smbclient的简单包装,用于查找可读和可写的SMB共享

    另一方面,smbclient运行正常。 因此,我为smbclient写了一个包装器,该包装器会自动测试所有找到的共享的读写权限。 验证是通过空会话(即没有用户名和密码)完成的。 脚本smbclientmap.sh执行以下操作: 该脚本将...

    node-samba-client:smbclient的Node.js包装器

    smbclient的Node.js包装器 要求 要求必须安装Node.js 10+ Smbclient。 可以使用sudo apt-get install smbclient安装在Ubuntu上。 原料药 const SambaClient = require ( 'samba-client' ) ; let client = new Samba...

    教育科研-学习工具-Linux服务端与windows客户端之间跨平台文件的传输方法.zip

    2. **SFTP (SSH File Transfer Protocol)**: SFTP利用SSH(Secure Shell)协议进行文件传输,提供安全的连接和数据加密。它常用于Linux服务器和Windows客户端之间的文件传输,尤其是在需要保护数据隐私的情况下。 3...

    Windows_Storage_Server_2008__共享设置

    - **Linux客户端访问**:在Linux主机中,确认网络配置正确后,使用`smbclient`命令查看NAS共享目录,并可通过`mount`命令将共享目录挂载至本地目录,实现跨平台文件访问与管理。 #### 扩容与NFS共享配置 - **扩展...

    JAVA SMB共享文件夹操作文件jar支持smb2、smb3.rar

    此RAR压缩包包含了几个关键的库文件,它们使得Java程序能够实现对SMB2和SMB3协议的支持。 1. **bcprov-jdk15to18-169.jar**:这是Bouncy Castle加密库的一个版本,提供广泛的加密算法和PKI(Public Key ...

    Build android development platform in Ubuntu 10.04.pdf

    #### 2. 获取Android内核源码并编译 这一部分将介绍如何获取Android内核源码以及编译流程。 ##### 2.1 获取Android内核源码 获取Android内核源码的方法与之前获取整个Android源码类似,主要区别在于源码仓库的...

    linux 文件共享

    4. **FTP (File Transfer Protocol)**: 虽然不如SFTP安全,FTP仍然是一个常见的文件共享选项。安装vsftpd或ProFTPD等FTP服务器,配置用户账户和权限,然后通过FTP客户端连接到服务器进行文件操作。 5. **WebDAV**: ...

    Samba服务器目录共享设置.doc

    - **gp2 目录**:`group1` 和 `group2` 用户可读,但只有 `group2` 用户可写。 - **public 目录**:所有人都只能读取。 3. **重启 Samba 服务**:同上。 4. **测试共享目录**: - 在 Windows 和 Debian 上测试...

    libsmbclient-devel-4.10.16-9.el7_9.i686.rpm

    官方离线安装包,亲测可用

    linux.chm文档

    usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 修改用户属性 passwd 修改口令 passwd user1 修改一个用户的口令 (只允许root执行) chage -E 2005-12-31 user1 设置用户口令的失效期限 ...

    智能判断多台设备局域网内通断情况、实现局域网内自动拷贝文件

    - FTP/FTPS/SFTP:通过FTP(File Transfer Protocol)、FTPS(FTP over SSL/TLS)或SFTP(Secure File Transfer Protocol),可以在安全的环境下进行文件传输。Python的ftplib和paramiko库提供了相应的支持。 - ...

    libsmbclient-devel-4.10.16-17.el7_9.x86_64.rpm

    官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装

    centos安装samba

    - **访问共享资源**:Samba 提供了一个类似于 FTP 客户端的工具叫做 `smbclient`,这个命令可以用来访问 Windows 共享或 Linux 提供的 Samba 共享。例如,可以通过命令 `smbclient //hostname/sharename -U ...

Global site tag (gtag.js) - Google Analytics