리눅스
sftp chroot 적용 우분투 ubuntu 22.04
내블로그주인
2023. 2. 23. 13:18
$ sudo apt update && sudo apt install openssh-server
$ sudo adduser --shell /bin/false 아이디
$ sudo mkdir -p /test/files <==저장하고자 하는 폴더
$ sudo chown 아이디:아이디 /test/files <==위에서 정한 폴더
$ sudo chown root:root /test <==정한 폴더 상위는 root 가 소유권 가져야함
$ sudo chmod 755 /test
$ sudo nano /etc/ssh/sshd_config
상기 파일에서 제일 아래에 아래 내용 추가
Match User 아이디
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /test
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
해당파일 저장하기
$ sudo sshd -t
$ sudo systemctl restart ssh
적용 후 확인하기
$ sftp 아이디@서버주소
$ ssh 아이디@서버주소
참고블로그
https://tecadmin.net/how-to-create-sftp-only-user-in-ubuntu-22-04/