http://blog.srmklive.com/2013/04/24/how-to-setup-sftp-server-ftp-over-ssh-in-ubuntu/

In my previous post, i discussed about how to install & configure FTP Server on Ubuntu. In this post, i will discuss about how to setup SFTP server in Ubuntu. First you need to install openssh-server, which can be done using command:

1 sudo apt-get install openssh-server ssh

You can use the following commands for ssh:

1 sudo service ssh start          # Starts SSH Servier
2 sudo service ssh restart        # Restarts SSH Server
3 sudo service ssh stop           # Stops SSH Server
4 sudo service ssh status         # Gives a short description of the status of the SSH server

First create a backup of the /etc/ssh/sshd_config file and name it as/etc/ssh/sshd_config.bak. When done, open the /etc/ssh/sshd_config file:

1 sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
2 sudo vi /etc/ssh/sshd_config

Now edit the file /etc/ssh/sshd_config and add/edit the following lines:

#Subsystem sftp /usr/lib/openssh/sftp-server
2 Subsystem sftp internal-sftp -f AUTH -1 VERBOSE
3  
4 #Uncomment this line if already commented
5 UsePAM yes
6  
7 AllowGroups sftpusers sftp root
8  
9 Match Group sftpusers
10 ChrootDirectory %h
11 AllowTCPForwarding no
12 X11Forwarding no
13 ForceCommand internal-sftp

这里如果你想加入其他的用户test,并将它的目录限定在/home/test目录,需要加入如下的内容:

执行如下命令:sudo usermod -a -G sftpusers test

再sshd_config中加入如下内容:
Match user test
ChrootDirectory /home/test
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp

为了不让test账户登录,可以设置/etc/passwd中的test账户为nologin。

Now lets create the relevant users & groups. First the create user group sftpusers using command:

1 sudo groupadd sftpusers

Now create a user suppose sftpuser. The commands listed below will create the user, add it to the sftpusers, and update its password

1 sudo adduser sftpuser
2 sudo usermod -a -G sftpusers sftpuser
3 sudo passwd sftpuser

Now proceed with modifying the permissions of the users home directory to allow for chrooting:

1 sudo chown root:sftpusers /home/sftpuser
2 sudo chmod 750 /home/sftpuser

Create a directory in which sftpuser is free to put any files in it:

1 sudo mkdir /home/sftpuser/public
2 sudo chown sftpuser:sftpusers /home/sftpuser/public
3 sudo chmod 777 /home/sftpuser/public

sftp的安装和使用的更多相关文章

  1. sublime sftp插件安装及时更新网站

    Sublime Text 2 本身并不强大,但是它方便使用插件扩展功能,所以变得很强大.今天介绍一个很实用的插件 SFTP ,可以大大提高前端工作效率. 常见的工作流程 有时候修改一些网站上的文件,通 ...

  2. sublime sftp 插件安装及破解

    必备插件sftp: 1,Package Control可以用来install其他package 2,sftp远程编辑文件:安装:install->sftp具体配置 sftp工具破解     1, ...

  3. Windows SFTP 的安装

    用于Windows系统的免费SFTP服务器-Free SFTP Servers 前不久,有人问我:“怎么从 Linux 系统传文件到 Windows 服务器,不能用 FTP 协议.” 文件数量不大.用 ...

  4. sftp 多用户安装与配置

    sftp 是 Secure File Transfer Protocol 的缩写,安全文件传送协议.可以为传输文件提供一种安全的加密方法.SFTP 为 SSH 的一部分,由于这种传输方式使用了加密/解 ...

  5. vmware安装cent os 6.5 + oracle 11g xe + jboss eap 6.2 + weblogic 12c+ webshpere mq 7.5

    前言: mac系统发展速度确实很快,短短数年,mac os上已经能网银支付(中行.招行.工商.支付宝等均已全面支持mac os了),windows上的经典常用软件:qq.飞信.旺旺.有道词典.有道云笔 ...

  6. 在 Sublime Text 2 中使用 SFTP 插件快速编辑远程服务器文件

    在 Sublime Text 2 中使用 SFTP 插件快速编辑远程服务器文件 开源程序 浏览:29555 2013年05月02日 文章目录[隐藏] 常见的工作流程 SFTP 安装和使用方法 第一步: ...

  7. Sublime Text 3 常用插件 —— SFTP

    在 Win 下常用 Xftp 软件来和远程服务传递文件,但是要是在项目开发的时候频繁的将远程文件拖到本地编辑然后再传回远程服务器,那真是麻烦无比,但是Sublime中SFTP插件,它让这世界美好了许多 ...

  8. centos 6.5 安装 tomcat8 及性能优化_虚拟主机

    Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP程序的首选. Tomcat和Nginx.Apa ...

  9. 我的代码库-Java8实现FTP与SFTP文件上传下载

    有网上的代码,也有自己的理解,代码备份 一般连接windows服务器使用FTP,连接linux服务器使用SFTP.linux都是通过SFTP上传文件,不需要额外安装,非要使用FTP的话,还得安装FTP ...

随机推荐

  1. Java学习之IO流总结

    ---恢复内容开始--- 流是用来读写数据的,java有一个类叫File,它封装的是文件的文件名,只是内存里面的一个对象,真正的文件是在硬盘上的一块区间,在这个文件里面存放着各种各样的数据,我们想读文 ...

  2. Android Studio 单刷《第一行代码》系列 02 —— 日志工具 LogCat

    前情提要(Previously) 本系列将使用 Android Studio 将<第一行代码>(书中讲解案例使用Eclipse)刷一遍,旨在为想入坑 Android 开发,并选择 Andr ...

  3. 查看JVM内存

    你知道如何进行JVM内存查看,这里和大家分享几个JVM内存查看方法,希望对你的学习有所帮助,通常情况下可以用代码查看,也可以在eclipse中增添相关信息后直接查看. JVM内存查看方法 可以用代码查 ...

  4. 8、android代码优化技术记录

    1.length.length().size的优化 举例: int array_one[] = {1,2,3,4,5,6,7,8,9,10}; int array_two[] = {1,2,3,4,5 ...

  5. Mysql数据库表排序规则不一致导致联表查询,索引不起作用问题

    Mysql数据库表排序规则不一致导致联表查询,索引不起作用问题 表更描述: 将mysql数据库中的worktask表添加ishaspic字段. 具体操作:(1)数据库worktask表新添是否有图片字 ...

  6. Django RequestContext用法

    模版中的变量由context中的值来替换,如果在多个页面模版中含有相同的变量,比如:每个页面都需要{{user}},笨办法就是在每个页面的请求视图中都把user放到context中.   from d ...

  7. Codeforces Round #352 (Div. 2) C. Recycling Bottles 暴力+贪心

    题目链接: http://codeforces.com/contest/672/problem/C 题意: 公园里有两个人一个垃圾桶和n个瓶子,现在这两个人需要把所有的瓶子扔进垃圾桶,给出人,垃圾桶, ...

  8. 【转载】oracle 分区表详解

    一.分区表的概述:     Oracle的表分区功能通过改善可管理性.性能和可用性,从而为各式应用程序带来了极大的好处.通常,分区可以使某些查询以及维护操作的性能大大提高.此外,分区还可以极大简化常见 ...

  9. poj 1815 Friendship 字典序最小+最小割

    题目链接:http://poj.org/problem?id=1815 In modern society, each person has his own friends. Since all th ...

  10. BZOJ 2653 middle

    AC通道:http://www.lydsy.com/JudgeOnline/problem.php?id=2653 题目大意:多组询问,求左右端点在规定范围内移动所能得到的最大中位数. [分析] 求中 ...