Centos6搭建sftp服务器
一、创建sftp相关用户和目录
[root@mail samba]# useradd -s /sbin/nologin -M sftp_user #创建一个系统用户,按需设置登录的shell和家目录
[root@mail samba]# passwd sftp_user #设置密码,也是sftp登录的密码,公网上尽可能复杂点 [root@mail samba]# mkdir /var/sftp/sftp_user -pv #创建sftp的根目录
[root@mail samba]# chown root:root -R /var/sftp/sftp_user #将属组和属主都设置为root,必须,这里最容易出错
[root@mail sftp_user]# cd /var/sftp/sftp_user/
[root@mail sftp_user]# mkdir public #创建共享目录
[root@mail sftp_user]# chown sftp_user:sftp_user -R /var/sftp/sftp_user/public/ #将共享目录的属组属主设为我们的sftp用户
二、编辑sshd配置文件,内容如下
# $OpenBSD: sshd_config,v 1.80 // :: djm Exp $ # This is the sshd server system-wide configuration file. See
# sshd_config() for more information. # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin # The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value. #Port
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress :: # Disable legacy (protocol version ) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol
Protocol 2 #支持的SSH协议的版本号 # HostKey for protocol version
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key # Lifetime and size of ephemeral version server key
#KeyRegenerationInterval 1h
#ServerKeyBits # Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV #将日志消息通过哪个日志子系统(facility)发送
#LogLevel INFO # Authentication: #LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries
#MaxSessions #RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes #允许通过密码进行登录 # Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no #是否允许质疑-应答(challenge-response)认证。默认值是"yes"。 # Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes # GSSAPI options
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes #是否在用户退出登录后自动销毁用户凭证缓存。默认值是"yes"。仅用于SSH-2。
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no # Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
UsePAM yes #是否启用pam认证 # Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES #指定客户端发送的哪些环境变量将会被传递到会话环境中。[注意]只有SSH-2协议支持环境变量的传递,可以设置多个
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS #AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes #是否允许进行 X11 转发。默认值是"no",设为"yes"表示允许
#X11DisplayOffset
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval
#ClientAliveCountMax
#ShowPatchLevel no
#PidFile /var/run/sshd.pid
#MaxStartups ::
#PermitTunnel no
#ChrootDirectory none # no default banner path
#Banner none # override default of no subsystems
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp #配置一个外部子系统,仅用于SSH-2协议。值是一个子系统的名字和对应的命令行(含选项和参数)。比如"sftp /usr/libexec/openssh/sftp-server"。,###这里配置为内部的
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
GSSAPIAuthentication no #是否允许使用基于 GSSAPI 的用户认证。默认值为"no"。仅用于SSH-2。
UseDNS no #是否对远程主机名进行反向解析
AllowTcpForwarding yes #是否允许TCP转发
Compression yes #是否对通信数据进行加密,还是延迟到认证成功之后再对通信数据加密
MaxAuthTries 6 #指定每个连接最大允许的认证次数。默认值是 6
PermitRootLogin yes #是否允许 root 登录
PrintMotd yes #是否在每一次交互式登录时打印 /etc/motd 文件的内容
PubkeyAuthentication yes #是否允许公钥认证。仅可以用于SSH-2。默认值为"yes"。
RSAAuthentication no #是否允许使用纯 RSA 公钥认证。仅用于SSH-1。默认值是"yes" Match User sftp_user #对特定的用户单独配置,匹配到的用户会强制使用/bin/false shell,只能以sftp登录,无法使用ssh登录服务器,没有匹配到的用户或组可以直接sftp登录,但是根目录为自己的家目录,无法指定具体的根目录。也可以设置为组,例如:Match Group sftp
ChrootDirectory /var/sftp/sftp_user/ #限定用户的根目录
X11Forwarding no
AllowTcpForwarding yes
ForceCommand internal-sftp #强制执行这里指定的命令而忽略客户端提供的任何命令
重启sshd服务
[root@mail sftp_user]# /etc/init.d/sshd restart
停止 sshd: [确定]
正在启动 sshd: [确定]
测试登录,这里使用winscp这款软件

输入我们之前设置的密码


登录成功
Centos6搭建sftp服务器的更多相关文章
- Linux Centos 6.6搭建SFTP服务器
Linux Centos 6.6搭建SFTP服务器 在Centos 6.6环境使用系统自带的internal-sftp搭建SFTP服务器. 打开命令终端窗口,按以下步骤操作. 0.查看openssh的 ...
- freeSSHD在windows环境下搭建SFTP服务器
freeSSHD在windows环境下搭建SFTP服务器 0 建议现在windows环境下安装cygwin,否则在windows环境下cmd模式使用不了sftp去连接,可以利用win scp去测试连接 ...
- Linux ---搭建SFTP服务器
在Centos 6.6环境使用系统自带的internal-sftp搭建SFTP服务器. 打开命令终端窗口,按以下步骤操作. 0.查看openssh的版本 ssh -V 使用ssh -V 命令来查看op ...
- windows 上搭建 sftp 服务器 -freesshd全过程( 在linux上部署逐浪CMS的必读教程)
文章标题: windows 上搭建 sftp 服务器 - freesshd全过程 关键字 : freesshd 文章分类: 教程 创建时间: 2020年3月23日 缘由 动手 第一步:添加用户 第二步 ...
- linux搭建sftp服务器
转自:http://blog.csdn.net/superswordsman/article/details/49331539 最近工作需要用到sftp服务器,被网上各种方法尤其是权限设置问题搞得晕头 ...
- Windows搭建SFTP服务器
1.项目需要搭建一个SFTP服务器,网上搜了一下,用的是freeSSHd软件,网上查一下我用的是1.3.1版本https://freesshd.updatestar.com/网址自己下载即可. 2.安 ...
- 搭建SFTP服务器,允许一个或多个用户拥有一个或多个目录的rwx权限
1.引言 sftp可以为传输文件提供一种安全的网络的加密方法.sftp 与 ftp 有着几乎一样的语法和功能.SFTP 为 SSH的其中一部分,是一种传输档案至 Blogger 伺服器的安全方式.其实 ...
- CentOS6搭建OpenVPN服务器
一.服务器端安装及配置 服务器环境:干净的CentOS6.3 64位系统 内网IP:10.143.80.116 外网IP:203.195.xxx.xxx OpenVPN版本:OpenVPN 2.3.2 ...
- linux如何搭建sftp服务器
工具/原料 centos7.2_x64 方法/步骤 创建sftp组 groupadd sftp 创建完成之后使用cat /etc/group命令组的信息 2 创建一个sftp用户mysft ...
随机推荐
- 谈谈我对Linux系统学习的历程回顾
众所周知,Windows 和Linux 是目前最流行的2个操作系统.Windows系统适合普通用户,它的优势是图形化界面,简单易用,使用起来门槛很低,很容易上手,所以,windows占有了大多数普 ...
- 微服务-注册与发现-zookeeper bydasn
目录 一.微服务注册的概述 二.zookeeper2.1 zookeeper安装启动2.2 zookeeper集群搭建2.3 zkcli操作 一.微服务注册概述 在微服务中,有这么一个东西叫服务注册表 ...
- day72 关于rbac组件的小部分面试题
rbac的权限组件 基于角色的权限控制 1.什么是权限? url代表的就是一个权限 2.如何实现权限的控制? 表结构 以我们讲的课的内容为例 菜单表: - title 标题 - icon 图标 ...
- LeetCode 33 搜索旋转排序数组
题目: 假设按照升序排序的数组在预先未知的某个点上进行了旋转. ( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] ). 搜索一个给定的目标值,如果数组中存在这个 ...
- java知识点归集
将工作中,或者看书的过程中碰到的自己之前没有掌握的知识点进行归纳,暂时就碰到什么写什么,后续有一定量的话进行整理: 1. list实现 相关文章:https://zhuanlan.zhihu.com ...
- Js 编程题汇总
Coding题: 1. 预测以下代码的输出结果: var Foo = function(a) { function bar() { console.log(a); }; this.baz = func ...
- 内存泄露java.lang.OutOfMemoryError: PermGen space解决方法
PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被 ...
- 二进制安装MySQL数据库
今天安装的是二进制的mysql包5.7.21的包,在配置文件的时候采了好多坑,左后还是搞定了,来和大家分享一下 二进制msyql5.7.21版本的主从复制安装 新建/picclife目录 mkdir ...
- Arch Linux root密码忘记了怎么办
https://wiki.archlinux.org/index.php/Reset_root_password_(简体中文)https://wiki.archlinux.org/index.php/ ...
- HTTP 各状态码大全
基本涵盖了所有问题 HTTP 400 – 请求无效 HTTP 401.1 – 未授权:登录失败 HTTP 401.2 – 未授权:服务器配置问题导致登录失败 HTTP 401.3 – ACL 禁止访问 ...