tftp or utftp Command Purpose Transfers files between hosts using the Trivial File Transfer Protocol (TFTP). Syntax {tftp | utftp} { -g | -o | -p | -r | -w } LocalName HostPort RemoteName [ netascii | image] Interactive Form Syntax Command Line Form Syntax Description The /usr/bin/tftp and utftp commands transfer files between hosts using the Trivial File Transfer Protocol (TFTP). Since TFTP is a minimal file transfer protocol, the tftp and utftp commands do not provide all of the features of the ftp command. For exam- ple, the tftp and utftp commands do not provide the ability to list remote files or change directories at the remote host, and only limited file access privileges are given to the remote TFTP server. The utftp command is a form of the tftp command for use in a pipe. The remote host must have a tftpd daemon started by its inetd daemon and have an account defined that limits the access of the tftpd daemon. Use the procedure defined by the tftpd command to setup the TFTP environment and the nobody account. Note: The tftp and utftp commands should not be available when your host is operating in secure mode. The tftp command ignores duplicate acknowledgments for any block sent and sends an error packet and exit if a block with an inap- propriate (future) block number arrives. It also ignores dupli- cate data blocks if they have already been received and sends an error packet and exits. Maximum Time-out Value The user can pick the maximum time-out value, but the initial time-out value for the first block is hardcoded. The user cannot pick the maximum time-out value for the server; the server times out after six retries with a maximum time-out value of 64 seconds. Access Control The /etc/tftpaccess.ctl file is searched for lines that start with allow: or deny:. Other lines are ignored. If the file doesn't exist, access is allowed. The allowed directories and files can be accessed and the denied directories cannot be ac- cessed. For example, the /usr directory might be allowed and the /usr/ucb directory might be denied. This means that any directo- ry or file in the /usr directory, except the /usr/ucb directory, can be accessed. The entries in the /etc/tftpaccess.ctl file must be absolute path names. The /etc/tftpaccess.ctl file should be write-only by the root user and readable by all groups and others (that is, owned by root with permissions of 644). The user nobody must be able to read the /etc/tftpaccess.ctl file. Otherwise, the tftpd daemon is not able to recognize the existence of the file and allows ac- cess to the entire system. For more information, refer to the sample tftpaccess.ctl file, which resides in the /usr/lpp/tcpip/samples directory. The search algorithm assumes that the local path name used in the tftp command is an absolute path name. It searches the /etc/tftpaccess.ctl file looking for allow:/. It repeatedly searches for allowed path names with each partial path name con- structed by adding the next component from the file path name. The longest path name matched is the one allowed. It then does the same with denied names, starting with the longest allowed path name matched. For example, if the file path name were /a/b/c and the /etc/tftpaccess.ctl file contained allow:/a/b and deny:/a, one allowed match would be made (/a/b) and no denied match starting with /a/b would be made, and access would be allowed. If the /etc/tftpaccess.ctl file contained allow:/a and deny:/a/b, one allowed match would be made (/a) and one denied match start- ing with /a (/a/b) would be made, and access would be denied. If the /etc/tftpaccess.ctl file contained allow:/a/b and also con- tained deny:/a/b, access would be denied because allowed names are searched first. Note: Further information and example configurations for Xsta- tions, Diskless clients, and restricted entry can be found in the /usr/lpp/tcpip/samples/tftpaccess.ctl file. The tftp and utftp commands have two forms: interactive form and command-line form. Interactive Form In the interactive form, the tftp and utftp commands are issued alone or with a Host parameter that specifies the default host to use for file transfers during this session. If you choose, you can also specify with the Port parameter which port the tftp or utftp connection should use, such as the one specified for mail in the /etc/services file. When you enter the interactive form of either of these commands, the tftp> prompt is displayed. When transferring data to a remote host, the transferred data is placed in the directory specified by the RemoteName parameter. The remote name must be a fully specified file name, and the re- mote file must both exist and have write permission set for oth- ers. The tftp command attempts to write the data to the speci- fied file. However, if the remote TFTP server does not have the appropriate privileges to write the remote file or if the file does not already exist, the transfer is unsuccessful. This can be overridden using the tftpd daemon. Command-Line Form The command-line forms of the tftp and utftp commands are equivalent, except that the utftp command does not overwrite a local file. The tftp command can overwrite a file, but prompts the user before doing so. Because it is not interactive, the command line form of the utftp command can be more useful than the tftp command in a pipe. In the command line form, all of the arguments to either command are specified on the command line, and no prompt is displayed. Subcommands The tftp and utftp subcommands can be entered in either their in- teractive form or in their command-line form. Subcommands Used in the Interactive Form Once the tftp> prompt is displayed, the following subcommands can be issued: ? [Subcommand] Displays help information. If a Subcommand param- eter is specified, only information about that subcommand is displayed. ascii Synonym for the mode ascii subcommand. binary Synonym for the mode binary subcommand. This subcommand is used in the interactive mode. The image subcommand accom- plishes the same thing as the mode binary subcommand, but is used on the command line. connect Host [Port] Sets the remote host, and optionally the port, for file transfers. Since the TFTP protocol does not main- tain connections between transfers, the connect subcommand does not create a connection to the specified host, but stores it for transfer operations. Because the remote host can be specified as part of the get or put subcommand, which overrides any host previously specified, the connect subcommand is not required. get RemoteFile [LocalFile] get RemoteFile RemoteFile RemoteFile [RemoteFile . . . ] Gets a file or set of files from the remote host to the local host. Each of the RemoteFile parameters can be specified in one of the following two ways: * As a file (File) that exists on the remote host if a default host has already been specified. * As a host file (Host:File), where Host is the remote host and File is the name of the file to copy to the local system. If this form of the parameter is used, the last host specified be- comes the default host for later transfers in this tftp session. mode Type Sets the type (Type) of transfer mode to either ascii or binary. A transfer mode of ascii is the default. put LocalFile [RemoteFile] put LocalFile LocalFile LocalFile [LocalFile . . . ] RemoteDirectory Puts a file or set of files from the local host onto the remote host. The RemoteDirectory and RemoteFile parame- ters can be specified in one of the following two ways: * As a file or directory that exists on the remote host if a de- fault host has already been specified. * With Host:RemoteFile parameter, where Host is the remote host and RemoteFile is the name of the file or directory on the remote system. If this form of the parameter is used, the last host specified becomes the default host for later transfers in this tftp session. In either case, the remote file or directory name must be a fully specified path name, even if the local and remote directories have the same name. If a remote directory is specified, the re- mote host is assumed to be a UNIX machine. The default value of the put subcommand is write-replace, but you can add an option in the tftpd daemon to allow write-create. quit Exits the tftp session. An End-Of-File key sequence also exits the program. status Shows the current status of the tftp program, including, for example, the current transfer mode (ascii or binary), connec- tion status, and time-out value. timeout Value Sets the total transmission time out to the number of seconds specified by the Value parameter. trace Turns packet tracing on or off. verbose Turns verbose mode, which displays additional information during file transfer, on or off. Subcommands Used in the Command Line Form In this form, if the Action flag is: -w or -p Writes (or puts) local data, specified by the LocalName parameter, to the file specified by the RemoteName parameter on the remote host specified by the Host parameter. If the LocalName parameter is a file name, the tftp command transfers the specified local file. If the LocalName parameter is speci- fied as a - (dash), the tftp command transfers data from local standard input to the remote host. When the LocalName parameter is standard input, the tftp command allows 25 seconds for all in- put to be entered before it times out. -r or -g or -o Reads (or gets) remote data from the file speci- fied by the RemoteName parameter at the remote host specified by the Host parameter and writes it to the file specified by the LocalName parameter. If the LocalName parameter is a file name, the tftp command writes the data to the specified local file. For the -r and -g actions, the tftp command prompts for verifica- tion before overwriting an existing local file. For the -o ac- tion, the tftp command overwrites an existing local file without prompting. If the LocalName parameter is specified as a - (dash), the tftp command writes the data to local standard out- put. Note: Since the tftp -g and tftp -r commands prompt before overwriting an existing local file, it may be impractical to use the tftp command in a pipe. The utftp command performs the same -r and -g actions as the tftp command, but simply stops before overwriting a local file. Thus, the utftp command may be more appropriate for use in a pipe. For both of the following modes of file transfer, the RemoteName parameter is the name of a file that has write permission set for others. Note that the RemoteName parameter must be in double quotes (" ") if it contains shell special characters. The mode of transfer is one of the following: netascii Transfers the data as 7-bit ASCII characters in 8-bit transfer bytes. This is the default. image Transfers the data as 8-bit binary data bytes in 8-bit transfer bytes, with no conversion. image transfer can be more efficient than netascii transfer when transferring between two hosts. It is recommended that netascii be used when transferring ASCII files from a workstation to a different type of host. Examples The following examples distinguish the differences between the interactive form and the command line form of the tftp command: Using the Interactive Form of the tftp Command To enter the tftp command, check the current status, connect to a remote host, and transfer a file from a remote host to your local host, enter: tftp The tftp> prompt is displayed. Enter the status subcommand fol- lowing this prompt: status A message similar to the following is displayed on your screen: Not connected. Mode: netascii Verbose: off Tracing: off Max-timeout: 25 seconds tftp> _ After the tftp> prompt, enter the connect subcommand and the name of the remote system to which you want to connect: tftp> connect host1 The tftp> prompt is displayed as an indication that you are con- nected to host1. Following the tftp> prompt, enter the get sub- command to transfer the file update from the remote host to your local host. get /home/alice/update update The /home/alice directory on the remote host must have read per- mission set for others. The /home/alice/update file from host1 was transferred to the update file on your local system. In this example, the user is connected to host1 and the update file is transferred from host1 to the local host. Using the Command Line Form of the tftp Command 1. To copy a text file from a remote host and write it to a local file, enter: tftp -g newsched host1 /home/john/schedule $ _ In this example, the /home/john/schedule file was copied from the remote host host1 and written to the local file newsched. 2. To copy a file from a remote host and redirect the output to standard output of the local host, enter: tftp -g - host3 /etc/hosts If the copy is successful, information similar to the following is displayed on your screen: 192.100.13.3 nameserver 192.100.13.3 host2 192.100.13.5 host1 192.100.13.7 host3 192.100.13.3 timeserver Received 128 bytes in 0.4 seconds $ _ In this example, the /etc/hosts file from remote host host3 was copied and the output redirected to standard output of the local host. 3. To copy a file from a remote host, pipe it to the grep command, and write it to a local file, enter: utftp -g - host1 /home/john/schedule | grep Jones > jones.todo $ _ In this example, the /home/john/schedule file was copied from the remote host host1. This file was then piped to the grep command and written into the local file jones.todo. 4. To copy a file to another system, enter: tftp -p /home/jeanne/test host2 /tmp/test If the copy is successful, information similar to the following is displayed on your screen: Sent 94146 bytes in 6.7 seconds In this example, the /home/jeanne/test file was sent to the /tmp directory on the remote host host2. 5. To copy a binary file to another system, enter: tftp -p core host3 /tmp/core image If the copy is successful, information similar to the following is displayed on your screen: Sent 309295 bytes in 15 seconds In this example, the binary file core from the current directory was sent to the /tmp directory on remote host host3. Implementation Specifics This command is part of the TCP/IP Facility in Network Facilities in Base Operating System (BOS) Runtime. Files /etc/tftpaccess.ctl Allows or denies access to files and direc- tories. Related Information The ftp command, grep command, rcp command. The ftpd daemon, inetd daemon, tftpd daemon, syslogd daemon. The hosts file format, services file format. Copying Files Using the tftp Command in AIX Version 3.2 System User's Guide: Communications. Network Overview in AIX Version 3.2 System User's Guide: Commun- ications. ================================================================= ================================================================= Copying Files Using the tftp Command tftp and utftp Uses the Trivial File Transfer Protocol (TFTP) to transfer files to and from hosts. Since TFTP is a single-file transfer protocol, the tftp and utftp commands do not provide all the features of the ftp command. If extra security is required for your network, the system manager can disable this command. Note: The tftp command is not available when your host is operat- ing at a high level of security. Prerequisites 1. If you wish to copy a file from a remote host, you must have read permission for the directory that contains the desired file. 2. If you wish to copy a file to a remote host, you must have write permission for the directory in which the file is to be placed. To Copy a File from a Remote Host 1. To establish a connection to a remote host, enter: tftp host1 In this example, host1 is the name of the host to which you wish to connect. 2. The tftp> prompt is displayed. To determine that a connection has been established, enter: status A message similar to the following will appear: Connected to host1 Mode: netascii Verbose: off Tracing: off Remxt-interval: 5 seconds, Max-timeout: 25 seconds tftp> 3. After the tftp> prompt, enter the get subcommand, the name of the file to be transferred, and the name to be assigned to the file on the remote system: get /home/alice/update update The /home/alice directory on the remote host must have read per- mission set for others. In this example, the /home/alice/update file is transferred from host1 to the update file in the current directory on the local system. 4. To end the session, enter: quit OR the Ctrl-D key sequence. To Copy a File to a Remote Host 1. To establish a connection to a remote host, enter: tftp host1 In this example, host1 is the name of the host to which you wish to connect. 2. The tftp> prompt is displayed. To determine that a connection has been established, enter: status A message similar to the following will appear: Connected to host1 Mode: netascii Verbose: off Tracing: off Remxt-interval: 5 seconds, Max-timeout: 25 seconds tftp> 3. After the tftp> prompt, enter the put subcommand, the name of the file to be transferred from the local host, and the path and file name for the file on the remote host: put myfile /home/alice/yourfile The /home/alice directory on the remote host must have write per- mission set for others. The myfile file, located in the user's current working directory, is transferred to host1. The path name must be specified unless a default has been established. The myfile file appears on the remote host as yourfile. 4. To end the session, enter: quit OR the Ctrl-D key sequence. Related Information The tftp command. The tftpd daemon.