ftp
From NetBSD Wiki
The ftp(1) command can be used to connect to FTP servers, but also to HTTP servers.
Contents |
Connecting via username and password
To connect using a username and password, just enter the servers hostname.
$ ftp ftp.myserver.com Trying 195.22.142.121... Connected to ftp.myserver.com. 220 Welcome to myserver.com ftp service. Name (ftp.myserver.com:melissa):
Connecting to anonymous FTP servers
Please use the option -a to connect anonymously:
$ ftp -a ftp.de.netbsd.org Trying 195.22.142.121... Connected to netbsd.portal-to-web.de. 220 Welcome to portal-to-web ftp service. 331 Please specify the password. 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>
Downloading via HTTP
$ ftp http://www.netbsd.org/guide/download/netbsd-en.pdf.gz Trying 204.152.190.12... Requesting http://www.netbsd.org/guide/download/netbsd-en.pdf.gz 100% |*************************************| 1849 KB 47.65 KB/s 00:00 ETA 1893957 bytes retrieved in 00:38 (47.65 KB/s)
The protocol prefix is mandatory in case of non-interactive downloads
Interactive mode
HTTP is only supported from the commandline, in interactive mode only FTP is available. If you connect to an FTP server like this
$ ftp server.example.com
it will proceed to ask for username (anonymous FTP username would generally be anonymous or ftp) and password (use your email address for anonymous access).
There should be no protocol prefix in case of interactive connections
After logging in, ftp presents you with a prompt where you may enter commands that get sent to the server. With the command help you can get information about the possible commands on the client, with the command rhelp you get information about the commands the server accepts.
To list files, do
ftp> ls
To download files, do
ftp> get filename
or
ftp> mget filename1 filename2
If you are allowed to upload files, use the commands put and mput to upload files.
ftp> put filename
Open ftp access
Your NetBSD distribution comes with closed-down ftp access. This means that in order to be able establish ftp session to your NetBSD computer you first have to grant user access to do so. Otherwise it provides you denial message.
Keep in mind security issues before you let other users to access your computer. To open-up ftp access you do:
1. Edit /etc/inetd.conf and uncomment line with ftp access, it should looks like:
ftp stream tcp nowait root /usr/libexec/ftpd ftpd-ll #ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd-ll
2. Edit /etc/ftpusers file, and set ALLOW for users you need to have ftp access, for an example:
# Deny various system users root deny toor deny daemon deny operator deny bin deny news deny games deny postfix deny named deny ntpd deny sshd deny smmsp deny uucp deny nobody deny
# All other users are allowed myuser allow
Where myuser is the name of user you are giving ftp access to.
3. You have to restart inetd daemon.
# cd /etc/rc.d # ./inetd restart
4. Always consider security issues. Ftp is made for your own administrators convenience. Only in rear times for an example local in-house installations you need to open root access.
Consider to look for pureftp.
Tips
In case you need grand to user wider ftp access, you edit /etc/ftpchroot file and add into following line:
userglob tnt
To change user home directory you edit /etc/ftpd.conf file by adding line:
homedir /
