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. 【PHP】iOS推送通知以及反馈服务

    近来项目是完成一个PHP的推送服务器,无论是PHP,APNs还是GCM基本上都是从零开始. 写下一点见解,方便以后继续做代码的搬运工. 因为对PHP跟iOS都不熟悉,可能有错漏...穷孩子没有用过iO ...

  2. Java Day 07

    构造函数 函数名与类名相同 不用定义返回值类型 没有具体的返回值 作用:给对象初始化值 默认构造函数 如果没有自己定义构造函数,系统会自动生成: 如果定义了,则默认构造函数不会自动生成. 构造函数与一 ...

  3. 程序调试手段之gdb, vxworks shell

    调试一个程序主要用到的功能: 启动程序 设置函数断点 设置数据断点 单步执行 查看内存值 修改内存值 linux下的gdb,和vxworks下的shell 虽然使用方式和调试命令略有不同,但是都能满足 ...

  4. 重新认识Box Model、IFC、BFC和Collapsing margins

    尊重原创,转载自: http://www.cnblogs.com/fsjohnhuang/p/5259121.html 肥子John^_^ 前言   盒子模型作为CSS基础中的基础,曾一度以为掌握了I ...

  5. boost之function

    boost中function是对函数指针和函数对象的进行封装的模板类. 定义示例:function<int()> func生成一个空的对象,表示函数参数个数为零,返回类型为int. #in ...

  6. 2012 Asia Chengdu Regional Contest

    Browsing History http://acm.hdu.edu.cn/showproblem.php?pid=4464 签到 #include<cstdio> #include&l ...

  7. /MT /MD /ML /MTd /MDd /MLd 的区别

    Multithreaded Libraries Performance The single-threaded CRT is no longer ( in vs2005 ) available. Th ...

  8. 项目分析 NGPcontext

    NGPcontext 之前对这个一直很疑惑,我一直认为只是在机器人方面有用处,但很有疑问,正在做这方面,我想好好看看到底是怎么运行的 bool NGP::init(NGPcontext context ...

  9. ios 获取n个月前或者n个月后的日期

    NSCalendar *calendar = [NSCalendar currentCalendar]; NSRange range = [calendar rangeOfUnit:NSDayCale ...

  10. 关于gzip压缩

    关于gzip压缩 http://httpd.apache.org/docs/2.0/mod/mod_deflate.html http://www.phpchina.com/resource/manu ...