Giter Club home page Giter Club logo

mini-sftp-server's Introduction

mini-sftp-server

因为SSH端口不允许公网访问,我又需求使用sftp上传/下载文件(我个人不想使用FTP服务器)。
所以我需要在Linux下部署一份sftp-server
要么我"Linux下让SSH和SFTP服务分离"(看着若干配置文件有点烦躁),
要么我找一个可用的sftp-server

程序没找到,不过找到了一个库:
pkg/sftp: SFTP support for the go.crypto/ssh package
我感觉着这个库还不错,更新还算活跃,应该会有人继续维护,
所以我准备对它进行一下封装,搞个sftp-server出来。

本程序以https://github.com/pkg/sftp为依赖库,
https://github.com/pkg/sftp/blob/master/examples/sftp-server/main.go为初版进行编写。

使用说明

  • 下载源码
    go get -u -v github.com/zx9229/mini-sftp-server

  • 查看帮助
    .\mini-sftp-server.exe -help

  • 使用示例
    首先,.\mini-sftp-server.exe -help > cfg.json
    然后,修改cfg.json文件。
    最后,.\mini-sftp-server.exe -conf cfg.json
    亦或者.\mini-sftp-server.exe -conf cfg.json -force

  • 配置文件的说明
    参见ConfigData.go顶部的注释。

其他说明

  • 我想(在Windows/Linux下)格式化JSON格式的配置文件
    stedolan/jq: Command-line JSON processor
    下载:wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32
    使用:./jq-linux32 . cfg.json > cfg.json

  • Windows下可以使用freeSSHd充当SFTP服务器。
    freeSSHd and freeFTPd - open source SSH and SFTP servers for Windows

  • Linux下可以利用OpenSSH建立SFTP服务器。
    略。

  • Windows下设置开机自启动程序(不依赖账户登录)
    思路:创建一个任务计划,它以系统账户(SYSTEM)运行,它在开机时(ONSTART)运行。无需账户登录。
    命令:SCHTASKS /Create /TN 任务名 /RU SYSTEM /SC ONSTART /TR 程序的路径和文件名
    示例:SCHTASKS /Create /TN MSFTPS /RU SYSTEM /SC ONSTART /TR "C:\exeFolder\msftps.exe -conf cfg.json"
    解释:创建一个任务计划,名为MSFTPS,运行命令是C:\exeFolder\msftps.exe -conf cfg.json
    注意:如果需要更细致的设置,请在任务计划程序里面进行设置。
    注意:测试的时候,请关闭防火墙!

  • Linux下设置开机自启动程序
    略。

备注说明

Windows下可以使用WinSCP连接该服务程序。
Linux下可以使用sshpasssftp填入密码:sshpass -p 密码 sftp -P 端口 用户名@主机:远程文件名 本地文件名
Linux下可以使用sshpasssftp填入密码:sshpass -p 密码 sftp -oPort=端口 用户名@主机:远程文件名 本地文件名

mini-sftp-server's People

Contributors

zaeouh avatar zhuxiang199202 avatar zx9229 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.