FTP Server Error FTP Connect No Route To Host Solution
FTP Server Error FTP Connect No Route To Host Solution
When setting up FTP server on Redhat 7 Linux box the following error message ftp:
connect: No route to host may pop-up during FTP client session:
ftp> ls
ftp>
# modprobe ip_conntrack_ftp
However, you will need to do this every time you reboot your RedHat server. Thus as
a more permanent solution you can persistently load this module after each reboot by
creating executable shell script within /etc/sysconfig/modules/ directory. Create
file /etc/sysconfig/modules/iptables.modules with the following content:
#!/bin/sh
Once you save this file you also need to make it executable:
# chmod +x /etc/sysconfig/modules/iptables.modules
The above script will load the following modules after each reboot:
nf_conntrack_ftp 18638 0
nf_conntrack 101024 9
nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,ip6table_nat,nf_conn
Title: Red Hat Enterprise Linux 7 - FTP Client Aborts With Error "Out
of memory" When Using 'mput' to Transfer Files
Object Name: emr_na-kc0132419en_us
Document Type: Support Information
Original owner: KCS - Linux
Disclosure level: Public
Version state: final
Environment
FACT:RHEL 7.2
FACT:ftp-0.17-66.el7
FACT:RHEL 6 versions prior to ftp-0.17-51.3
Questions/Symptoms
SYMPTOM:
ftp: Out of memory
Cause
CAUSE:ftp client available in RHEL 7.2 fails with error "Out of
memory"
when attempting to transfer multiple files with 'mput':
# ftp dl980g7
Connected to dl980g7 (10.26.8.8).
220 (vsFTPd 2.2.2)
Name (dl980g7:root): test
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> mput host*
# echo $?
1
The latest RHEL 6 ftp client does not suffer from this problem;
the later
RHEL 6 ftp RPM changelog contains:
ek <[email protected]>
- 0.17-51.2
- fix 'Out of memory' message when stacksize is set to unlimited
- Resolves: #783868
However, the RHEL 7 changelog does not list these changes. This
is a bug in
the RHEL 7 ftp client; the RHEL 6 "unlimited stack" errata was
not included
in RHEL 7.
Answer/Solution
FIX:Red Hat identifies the problem on RHEL6 is due to an
unlimited stack
size in the shell environment.
# ulimit -s 8192
2. Use 'sftp' instead. The secure ftp client uses the standard
'sshd' server
and is strongly recommended.
In this article, we discuss how to remedy the following error message in VSFTPD.
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
Preflight Check
These instructions are intended specifically for solving the error:
500 OOPS: vsftpd: refusing to run with writable root inside chroot().
We will be working from a Liquid Web Self Managed Fedora 32 server, and logged in as
the root user.
How to Repair
This error may occur when attempting to connect to a vsftpd FTP server that is
configured to jail (prevent from accessing other directories) each FTP user. It is best
practice to create Linux users specifically for FTP, that can't log in via SSH. For example,
if you wanted to remove SSH access for testuser, then you'd use the following
command:
However, that won't address the problem listed in the error. To do this, we must modify
the user's home directory to read only. Assuming the username is testuser and the
home directory is /home/testuser, then execute the following command:
By
2. The client initiates a conversation with the server when the user requests
to download a file.
3. Using FTP, a client can upload, download, delete, rename, move and copy
files on a server.
Users can work with FTP via a simple command-line interface -- from a
console or terminal window in Microsoft Windows, Apple macOS or Linux -- or
with a dedicated graphical user interface. Web browsers can also serve as
FTP clients.
Why is FTP important and what is it used for?
FTP is a standard network protocol that can enable expansive file transfer
capabilities across IP networks. Without FTP, file and data transfer can be
managed with other mechanisms -- such as email or an HTTP web service --
but those other options lack the clarity of focus, precision and control that FTP
enables.
FTP is used for file transfers between one system and another, and it has
several common use cases, including the following:
FTP has also undergone several updates to enhance FTP security. These
include versions that encrypt via an implicit TLS connection (FTPS) or explicit
TLS connection (FTPES) or that work with SFTP.
By default, FTP does not encrypt traffic, and individuals can capture packets
to read usernames, passwords and other data. By encrypting FTP with FTPS
or FTPES, data is protected, limiting the ability of an attacker to eavesdrop on
a connection and steal data.
FTP may still be vulnerable to brute-force attacks against user/password
authentication spoofing, an FTP bounce attack or a distributed denial-of-
service attack.
History of FTP
The first specification for FTP was published as RFC 114 on April 16, 1971,
and was written by Abhay Bhushan, then a student at the Massachusetts
Institute of Technology. The original idea behind FTP was to enable the
transfer of files over ARPANET, the precursor to the internet.
As the modern internet began to take shape, the FTP specification underwent
several revisions to align with networking standards, including TCP/IP. In
1980, a new version of FTP was defined in RFC 765 by Jon Postel, a
research scientist at the Information Sciences Institute at the University of
Southern California at the time. Five years later, FTP was redefined yet again
with RFC 959, which introduced new management capabilities for the
protocol, including the ability to make and remove a file directory. Prior
iterations of FTP were largely limited to transferring files to and from existing
file directory structures.
In 1997, RFC 959 was updated with new capabilities defined in RFC 2228 to
provide security capabilities. Two years later, FTP was updated with RFC
2428 to support the IPv6 protocol.
FTP clients
FTP clients are used to upload, download and manage files on a server. FTP
clients include the following:
FileZilla. This is a free FTP client for Windows, macOS and Linux that
supports FTP, FTPS and SFTP.
Transmit. This is an FTP client for macOS that supports FTP and SSH.
WinSCP. This is a Windows FTP client that supports FTP, SSH and SFTP.
The second digit is a grouping digit and encodes the following information:
Range Purpose
x0x Syntax
These replies refer to syntax errors, syntactically correct commands that don’t fit any
functional category, unimplemented or superfluous commands.
x1x Information
These are replies to requests for information, such as status or help.
x2x Connections
Replies referring to the control and data connections.
x3x Authentication and accounting
Replies for the login process and accounting procedures.
x4x Unspecified as of RFC 959.
x5x File system
These replies indicate the status of the Server file system vis-a-vis the requested
transfer or other file system action.
Below is a list of all known return codes that may be issued by an FTP server.
100 Series The requested action is being initiated, expect another reply before
proceeding with a new command
110 Restart marker reply. In this case, the text is exact and not left to the particular
implementation; it must read: MARK yyyy = mmmm where yyyy is User-process data
stream marker, and mmmm server’s equivalent marker (note the spaces between
markers and “=”).
120 Service ready in nnn minutes.
125 Data connection already open; transfer starting.
150 File status okay; about to open data connection.
200 Command okay.
202 Command not implemented, superfluous at this site.
211 System status, or system help reply.
212 Directory status.
213 File status.
214 Help message.On how to use the server or the meaning of a particular non-standard
command. This reply is useful only to the human user.
215 NAME system type. Where NAME is an official system name from the list in the
Assigned Numbers document.
220 Service ready for new user.
221 Service closing control connection.
225 Data connection open; no transfer in progress.
226 Closing data connection. Requested file action successful (for example, file transfer
or file abort).
227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
230 User logged in, proceed. Logged out if appropriate.
250 Requested file action okay, completed.
257 “PATHNAME” created.
331 User name okay, need password.
332 Need account for login.
350 Requested file action pending further information
421 Service not available, closing control connection.This may be a reply to any
command if the service knows it must shut down.
425 Can’t open data connection.
426 Connection closed; transfer aborted.
450 Requested file action not taken.
451 Requested action aborted. Local error in processing.
452 Requested action not taken. Insufficient storage space in system.File unavailable
(e.g., file busy).
500 Syntax error, command unrecognized. This may include errors such as command
line too long.
501 Syntax error in parameters or arguments.
502 Command not implemented.
503 Bad sequence of commands.
504 Command not implemented for that parameter.
530 Not logged in.
532 Need account for storing files.
550 Requested action not taken. File unavailable (e.g., file not found, no access).
551 Requested action aborted. Page type unknown.
552 Requested file action aborted. Exceeded storage allocation (for current directory or
dataset).
553 Requested action not taken. File name not allowed.
600 Series Replies regarding confidentiality and integrity
631 Integrity protected reply.
632 Confidentiality and integrity protected reply.
633 Confidentiality protected reply.
10000 Series Common Winsock Error Codes (These are not FTP return codes)
10054 Connection reset by peer. The connection was forcibly closed by the remote host.
10060 Cannot connect to remote server.
10061 Cannot connect to remote server. The connection is actively refused by the
server.
10066 Directory not empty.
10068 Too many users, server is full.
Important FTP Commands Cheat sheet
A list of FTP commands that may be sent to an FTP server, including all commands that
are standardized in RFC 959 by the IETF (Internet Engineering Task Force).
English
Environment
Issue
FTP client getting error 425 Failed to establish connection, while listing directory contents in
RHEL 7
FTP server gets "connection refused" when establishing Active FTP to FTP client
FTP client logs show:
Raw
200 PORT command successful. Consider using PASV.
425 Failed to establish connection.
Raw
type=AVC msg=audit(1404410045.618:1404): avc: denied { name_connect } for
pid=30686 comm="vsftpd" dest=63853 scontext=system_u:system_r:ftpd_t:s0-s0:c0.c1023
tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket
Resolution
The default SELinux policy in early RHEL7 denies the FTP server (executing in ftpd_t) access
to connect to high-numbered sockets (in unreserved_port_t).
Diagnostic Steps
Raw
19304 20:30:09.759007 socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 6 <0.000058>
19304 20:30:09.759095 setsockopt(6, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 <0.000011>
19304 20:30:09.759148 bind(6, {sa_family=AF_INET, sin_port=htons(20),
sin_addr=inet_addr("10.0.0.27")}, 16) = 0 <0.000113>
19304 20:30:09.759387 connect(6, {sa_family=AF_INET, sin_port=htons(61519),
sin_addr=inet_addr("10.0.0.101")}, 16) = -1 EACCES (Permission denied) <0.000162>
Raw
# getsebool -a | grep ftp
ftpd_connect_all_unreserved --> off