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. 28335 AD 转换

    #include "DSP2833x_Device.h"#include "DSP2833x_Examples.h" void Ad_init(void){ I ...

  2. 调用webservice客户端方法 runtime modeler error: Wrapper class ××× is not found. Have you run APT to generate them?

    用wsimport生成webservice的客户端以后,调用客户端生成方法时总是出现 runtime modeler error: Wrapper class stardand.nrcms.nckin ...

  3. typings的理解

    简介一些js库扩展了JavaScript的特性和语法,但是TypeScript编译器并不识别,通过typings.json配置可以辅助IDE,给出有智能的提示信息,以及重构的依据.因此需要在typin ...

  4. ABAP文本编辑框操作

    * 1.创建文本框 DATA: g_container TYPE REF TO cl_gui_custom_container, g_editor TYPE REF TO cl_gui_textedi ...

  5. 修改Input中Placeholder默认提示颜色(兼容)

    input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #f00; } input:-moz-pl ...

  6. 如何ping通两台计算机

    如何ping通两台计算机 因为ping是基于IP协议的,所以,先要保证两台计算机在同一个子网中,这里涉及到vlan和子网的概念 若两台主机不在同一个子网中则无法ping通 若两台主机在同一个子网中却p ...

  7. VMM学习-vmm_log

    功能类似verilog里的$display函数,在vmm里做了强化,可以在仿真过程中看到整个平台的运行信息,用来调试仿真平台. 函数原型在vmm.sv里(class vmm_log;),其构造函数为e ...

  8. Extjs中TextField中显示图标

    现看实现效果:   实现代码: { width:500, height : 25, fieldLabel : '过滤条件', itemId : 'queryText', labelAlign : 'r ...

  9. Oracle系列教程

    推荐博客:http://blog.csdn.net/leshami 具体知识点总结: 1.oracle安装:http://www.cnblogs.com/bluepoint2009/p/oracle- ...

  10. 阿里云centos配置ftp和svn全过程

    1.下载xshell 2.登录centos 3.安装vsftpd [root@xxx]# yum install vsftpd //安装vsftpd [root@xxx]# chkconfig vsf ...