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