Friday, 29 March 2013

/etc/services

The /etc/services file specifies which port a program must use when it connects to a UNIX or Linux machine. I tested this example using UBUNTU on my stand-alone PC so the connections are made to localhost. According to /etc/services, you must connect via port 21 if you wish to use ftp: 

UBUNTU > cat /etc/services|grep ftp
ftp-data        20/tcp
ftp             21/tcp
tftp            69/udp
sftp            115/tcp
ftps-data       989/tcp             # FTP over SSL (data)
ftps            990/tcp
venus-se        2431/udp            # udp sftp side effect
codasrv-se      2433/udp            # udp sftp side effect
gsiftp          2811/tcp
gsiftp          2811/udp
frox            2121/tcp            # frox: caching ftp proxy
zope-ftp        8021/tcp            # zope management by ftp
UBUNTU > ftp localhost 21
Connected to localhost.
220 (vsFTPd 2.3.5)
Name (localhost:andrew):
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/andrew"
ftp>

… but if you try using a different port, you are rejected:
 
UBUNTU > ftp localhost 42
ftp: connect: Connection refused
ftp>