Как примонтировать ftp папку в linux

Монтирование FTP шары в Linux c использованием ftpfs

Доступен в EPEL-репозитории. Начиная с версии CentOS 6.7 репозиторий вшит в ОС.

Шаг 2. Подключение FTP

На данном этапе создадим папку, куда будет монтироваться хранилище и подключим его.

Проверим успешное монтирование хранилища:

[root@test public_html]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root
8,9G 4,9G 3,6G 58% /
tmpfs 2,1G 0 2,1G 0% /dev/shm
/dev/sda1 500M 59M 415M 13% /boot
curlftpfs#ftp://testhost:[email protected]/
8,2T 0 8,2T 0% /home/ftp_share

Шаг 3. Автоматическое монтирование

Для автоматического монтирования хранилища при запуске системы, необходимо добавить строчку в /etc/fstab

curlftpfs#ftp://testhost:[email protected] /home/ftp_share fuse defaults 0 0

Шаг 4. Настройка Iptables

Если на сервере включен Firewall, необходимо прописать правила, позволяющие работать протоколу FTP как в активном, так и в пассивном режимах, для этого сначала загрузим модуль modprobe ip_conntrack_ftp , а затем добавим правила в таблицу:

iptables -A INPUT -p tcp -m tcp —dport 21 -m conntrack —ctstate ESTABLISHED -j ACCEPT -m comment —comment «Allow ftp connections on port 21»
iptables -A OUTPUT -p tcp -m tcp —dport 21 -m conntrack —ctstate NEW,ESTABLISHED -j ACCEPT -m comment —comment «Allow ftp connections on port 21»
iptables -A INPUT -p tcp -m tcp —dport 20 -m conntrack —ctstate ESTABLISHED,RELATED -j ACCEPT -m comment —comment «Allow ftp connections on port 20»
iptables -A OUTPUT -p tcp -m tcp —dport 20 -m conntrack —ctstate ESTABLISHED -j ACCEPT -m comment —comment «Allow ftp connections on port 20»

Читайте также:  Linux terminal поиск файлов

Источник

CurlFtpFS

CurlFtpFS is a filesystem for accessing FTP hosts based on FUSE and libcurl.

Installation

Make sure the kernel module has been loaded.

Mount FTP folder as root

Create the mount point and then mount the FTP folder.

# mkdir /mnt/ftp # curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password

If you want to give other (regular) users access right, use the allow_other option:

# curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password,allow_other

Do not add space after the comma or the allow_other argument will not be recognized.

To use FTP in active mode add the option ftp_port=- :

# curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password,allow_other,ftp_port=-

You can add this line to /etc/fstab to mount automatically.

curlftpfs#USER:PASSWORD@ftp.example.com /mnt/exampleorg fuse auto,user,uid=1000,allow_other,_netdev 0 0

Tip: You can use codepage when having problems with non-US English characters on servers that do not support UTF8, e.g. codepage=»iso8859-1″ .

To prevent the password to be shown in the process list, create a .netrc file in the home directory of the user running curlftpfs and chmod 600 with the following content:

machine ftp.example.com login username password mypassword

Mount FTP folder as normal user

You can also mount as normal user (always use the .netrc file for the credentials and ssl encryption!):

$ mkdir ~/example $ curlftpfs -o ssl,utf8 ftp://example.com/ ~/example
Error connecting to ftp: QUOT command failed with 500

then the server does not support the utf8 option. Leave it out and all will be fine.

Connect to encrypted server

In its default settings, CurlFtpFS will authenticate in cleartext when connecting to a non encrypted connection port. If the remote server is configured to refuse non encrypted authentication method / force encrypted authentication, CurlFtpFS will return a

# Error connecting to ftp: Access denied: 530

To authenticate to the ftp server using explicit encrypted authentication, you must specify the ssl option.

# curlftpfs ftp.example.com /mnt/ftp/ -o ssl,user=username:password

If your server uses a self-generated certificate not trusted by your computer, you can specify to ignore it

# curlftpfs ftp.example.com /mnt/ftp/ -o ssl,no_verify_peer,no_verify_hostname,user=username:password

For more details, see the curlftpfs(1) man page.

Читайте также:  Linux library file path

Troubleshooting

Unable to access files with non percent-encoded characters in their filename

This is a bug which has been initially reported in Launchpad bug 783033 in 2011 regarding paths with «#», confirmed in 2013 with no further activity. An upstream bug report links to a potential patch, which also fixes a breaking change in curl .

  • This page was last edited on 22 April 2023, at 15:08.
  • Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.
  • Privacy policy
  • About ArchWiki
  • Disclaimers

Источник

Монтирование FTP шары в Linux c использованием ftpfs

Доступен в EPEL-репозитории. Начиная с версии CentOS 6.7 репозиторий вшит в ОС.

Шаг 2. Подключение FTP

На данном этапе создадим папку, куда будет монтироваться хранилище и подключим его.

Проверим успешное монтирование хранилища:

[root@test public_html]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root
8,9G 4,9G 3,6G 58% /
tmpfs 2,1G 0 2,1G 0% /dev/shm
/dev/sda1 500M 59M 415M 13% /boot
curlftpfs#ftp://testhost:[email protected]/
8,2T 0 8,2T 0% /home/ftp_share

Шаг 3. Автоматическое монтирование

Для автоматического монтирования хранилища при запуске системы, необходимо добавить строчку в /etc/fstab

curlftpfs#ftp://testhost:[email protected] /home/ftp_share fuse defaults 0 0

Шаг 4. Настройка Iptables

Если на сервере включен Firewall, необходимо прописать правила, позволяющие работать протоколу FTP как в активном, так и в пассивном режимах, для этого сначала загрузим модуль modprobe ip_conntrack_ftp , а затем добавим правила в таблицу:

iptables -A INPUT -p tcp -m tcp —dport 21 -m conntrack —ctstate ESTABLISHED -j ACCEPT -m comment —comment «Allow ftp connections on port 21»
iptables -A OUTPUT -p tcp -m tcp —dport 21 -m conntrack —ctstate NEW,ESTABLISHED -j ACCEPT -m comment —comment «Allow ftp connections on port 21»
iptables -A INPUT -p tcp -m tcp —dport 20 -m conntrack —ctstate ESTABLISHED,RELATED -j ACCEPT -m comment —comment «Allow ftp connections on port 20»
iptables -A OUTPUT -p tcp -m tcp —dport 20 -m conntrack —ctstate ESTABLISHED -j ACCEPT -m comment —comment «Allow ftp connections on port 20»

Читайте также:  Making directory in linux

Источник

Оцените статью
Adblock
detector