乌班图搭建sftp服务器

1.登录乌班图服务器

Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Sun Aug 19 21:58:51 2018 from 192.168.1.12
ubuntu@ubuntu:~$ sudo su
[sudo] password for ubuntu: 
Sorry, try again.
[sudo] password for ubuntu: 

 

2.创建sftp的组和用户

root@ubuntu:/home/ubuntu# apt-get install -y openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssh-server is already the newest version (1:7.2p2-4ubuntu2.4).
0 upgraded, 0 newly installed, 0 to remove and 78 not upgraded.

3.添加sftp组合用户
root@ubuntu:/home/ubuntu# groupadd sftp-users
root@ubuntu:/home/ubuntu# mkdir /home/test
root@ubuntu:/home/ubuntu# useradd -d /home/test test
root@ubuntu:/home/ubuntu# passwd test
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@ubuntu:/home/ubuntu# usermod -a -G sftp-users -s /bin/false test

4.创建ssh用户组及用户管理
root@ubuntu:/home/ubuntu# groupadd ssh-users
root@ubuntu:/home/ubuntu# usermod -a -G ssh-users ubuntu
root@ubuntu:/home/ubuntu# mkdir /home/volume
root@ubuntu:/home/ubuntu# mkdir /home/volume/vod
root@ubuntu:/home/ubuntu# chown ubuntu:sftp-users /home/ubuntu/vod
chown: cannot access '/home/ubuntu/vod': No such file or directory
root@ubuntu:/home/ubuntu# chown ubuntu:sftp-users /home/volume/vod
root@ubuntu:/home/ubuntu# chmod 770 /home/volume/vod
root@ubuntu:/home/ubuntu# vi /etc/ssh/sshd_config

root@ubuntu:/home/ubuntu# reboot
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(server_2) at 13:06:59.


root@ubuntu:/home/ubuntu# sftp test@192.168.1.123
The authenticity of host '192.168.1.123 (192.168.1.123)' can't be established.
ECDSA key fingerprint is SHA256:BwNFVkebBp2PCKg1OHvQmWI1ChcAS1pegPSetDcBcGo.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.123' (ECDSA) to the list of known hosts.
test@192.168.1.123's password: 
Connected to 192.168.1.123.
sftp> quit
root@ubuntu:/home/ubuntu# cd /home/vod
bash: cd: /home/vod: No such file or directory
root@ubuntu:/home/ubuntu# cd home
bash: cd: home: No such file or directory
root@ubuntu:/home/ubuntu# cd /home/volume
root@ubuntu:/home/volume# cd vod
root@ubuntu:/home/volume/vod# touch 1.txt

sftp端口22改为13022,修改SSH两个配置文件:/etc/ssh/ssh_config和/etc/ssh/sshd_config并重启

root@ubuntu:/home/volume/vod# vim /etc/ssh/ssh_config
root@ubuntu:/home/volume/vod# vim /etc/ssh/sshd_config
root@ubuntu:/home/volume/vod# service ssh restart
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值