← Back to list

Setup ftp & sftp

Setting up ftp & sftp is old devops tasks. There are more mature protocol available. However, multiple companies yet using the old…

NIRAV SHAH · 2021-02-24 12:22 · 0 claps · 2.3 min read
#ftp #sftp #gcp #vsftp #linux
Open on Medium ↗
Wiki topics: FT · Fine-tuning & Adaptation ☁️ · DevOps & Cloud 🔓 · Open Source

Setup ftp & sftp

Setting up ftp & sftp is old devops tasks. There are more mature protocol available. However, multiple companies yet using the old protocols. Let’s see how we can setup the environment.

ftp & sftp both protocol works with linux user creation process. We can add few configuration to avoid error while connecting throgh filezilla or winscp.

Create instance on google cloud

gcloud beta compute instances create ftpserver \ 
    --project=my-dev --zone=asia-south1-a \
    --machine-type=e2-medium \
    --subnet=my-subnetwork --network-tier=PREMIUM --tags=ftpserver\
    --maintenance-policy=MIGRATE \
    --image=centos-7-v20210217 --image-project=centos-cloud \
    --boot-disk-size=100GB --boot-disk-type=pd-balanced \
    --boot-disk-device-name=ftpserver \
    --no-shielded-secure-boot \
    --shielded-vtpm --shielded-integrity-monitoring \
    --reservation-affinity=any

Setup network rule

gcloud compute firewall-rules create network-allow-ftp-sftp \
  --project=my-dev --network=my-network \
  --direction=INGRESS --priority=1000 --action=ALLOW \
  --rules=tcp:21,22,1023 --source-ranges=0.0.0.0/0 \
  --target-tags=ftpserver

Install & configure vsftp

sudo yum update
sudo yum install vsftpd
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
sudo firewall-cmd --zone=public --permanent --add-port=21/tcp
sudo firewall-cmd --zone=public --permanent --add-service=ftp
sudo firewall-cmd –-reload
sudo firewall-cmd --reload
sudo cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.default
sudo vi /etc/vsftpd/vsftpd.conf

Change in vsftpd configuration file

# Enable writing to the folders for linux users
anonymous_enable=NO
local_enable=YES
write_enable=YES
# Create jail for user to his directory
chroot_local_user=YES
allow_writeable_chroot=YES
# ssh user list
userlist_enable=YES
userlist_file=/etc/vsftpd/user_list
userlist_deny=NO

Script for creating ftp user

[root@ftpserver ~]# cat ftpuser.sh 
echo creating user for $ftpuser
sudo adduser $ftpuser
sudo passwd $ftpuser
echo $ftpuser | sudo tee –a /etc/vsftpd/user_list
sudo mkdir -p /home/$ftpuser/ftp/upload
sudo chmod 550 /home/$ftpuser/ftp
sudo chmod 750 /home/$ftpuser/ftp/upload
sudo chown -R $ftpuser: /home/$ftpuser/ftp
sudo chmod a-w /home/$ftpuser
sudo systemctl restart vsftpd
export ftpuser=srikanth
sh +x ftpuser.sh

Setup sftp server configuration

vi /etc/ssh/sshd_config
# modify uncomment below
PasswordAuthentication yes
# Add bottom of the configuration
Match Group sftp_users
ChrootDirectory /data/%u
ForceCommand internal-sftp

Restart services

#for ftp
systemctl restart vsftpd
#for sftp
systemctl restart sshd

Script for creating sftp user

[root@ftpserver ~]# cat sftpuser.sh 
echo creating user for $sftpuser
useradd -g sftp_users -d /upload -s /sbin/nologin $sftpuser
passwd $sftpuser
mkdir -p /data/$sftpuser/upload
chown -R root:sftp_users /data/$sftpuser
chown -R $sftpuser:sftp_users /data/$sftpuser/upload
export sftpuser=mysftp
sh +x sftpuser.sh

This are traditional ways of ftp & sftp, now you can have ftp & sftp with cloud storage, check links below. You can have managed ftp or sftp instances too.

Reference:

[embed]Error "530: permission denied" when user logs in to vsftpd server via ftp The cause is that if the parameter userlist_enable in file /etc/vsftpd/vsftpd.conf is YES and the parameter…www.thegeekdiary.com

[embed]Filezilla FTP Server Fails to Retrieve Directory Listing Ok this helped a lot, I couldn't find a fix. Simply, I already port forwarded the FTP port to my server. (The default…stackoverflow.com

[embed]kolban-google/sftp-gcs SFTP is the ability to transfer files using a protocol built on top of SSH. Currently, GCP does not have any…github.com

[embed]SFTP access to Google Cloud Storage Google Cloud Storage (GCS) provides blob storage for data. Files can be uploaded to GCS and subsequently retrieved. The…medium.com

[embed]How to set up an SFTP server on Linux These steps walk you through the process of setting up an SFTP server on Linux for the secure transfer of files for…www.techrepublic.com

[embed]Installing FileMage Gateway on the Google Cloud Platform | FileMage Gateway Documentation FileMage Gateway is available on the Google Cloud Platform as a virtual machine (VM) image. The VM image contains a…docs.filemage.io

[embed]How to Setup & Install an FTP Server With VSFTPD on CentOS 7 FTP stands for File Transfer Protocol. It has been a standard method for transferring files between computers for…phoenixnap.com


메타데이터
post_id
db454fded075
slug
setup-ftp-sftp-db454fded075
url
https://medium.com/@niravshah2705/setup-ftp-sftp-db454fded075
canonical_url
https://medium.com/@niravshah2705/setup-ftp-sftp-db454fded075
author_url
https://medium.com/@niravshah2705
status
ok
fetched_at
2026-07-28 12:19:09