-
Notifications
You must be signed in to change notification settings - Fork 3
/
ftp
47 lines (34 loc) · 1.67 KB
/
ftp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# install lftp command
sudo apt-get install -y lftp
# use wget to download ftp directory
wget -r --user="user@login" --password="Pa$$wo|^D" ftp://server.com/
# skip create files.
wget -r -nH --cut-dirs=5 -nc ftp://user:pass@server//absolute/path/to/directory
wget -m ftp://username:[email protected]/
wget -m ftp://username:[email protected]/htdocs
# mount ftp
sudo apt-get install -y curlftpfs
curlftpfs -o allow_other,allow_root,user=ftp-user:ftp-pass my-ftp-location.local /mnt/my_ftp/
# or
Mount ftp with curlftpfs using /etc/fstab
Since we do not want put any passwords to /etc/fstab file we will first create a /root/.netrc file with a ftp username and password using this format:
machine my-ftp-location.local
login ftp-user
password ftp-pass
Now change permissions of this file to 600:
# chmod 600 /root/.netrc
Check uid and gid of your non-root user. This user will have a access to ftp mount directory:
$ id
In the next step add a following line to your /etc/fstab file ( change credentials for your ftp user ):
curlftpfs#my-ftp-location.local /mnt/my_ftp fuse allow_other,uid=1000,gid=1000,umask=0022 0 0
Now mount ftp with:
mount -a
# mount ftp by fstab
# Add the curlftpfs mount into fstab to make it mount everytime the system is started (pico /etc/fstab)
curlftpfs#{username}:{password}@{host} /mnt/ftpbackup fuse rw,allow_other,uid={userid},_netdev 0 0
{username} = FTP username
{password} = FTP password
{host} = FTP host/ip
{userid} = ID of a local user (ex. 1001)
_netdev
The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).