ubuntuにて tftpを一行で実行する:atftp



手元にあるubuntu22.04 LTSではtftpが一行で実施できないので、atftpを導入してみました。


$ sudo apt-get install atftp
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libgnutls-openssl27 libsecret-1-0 libsecret-common
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 61 not upgraded.
Need to get 32.2 kB of archives.
After this operation, 99.3 kB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 atftp amd64 0.7.git20210915-4build1 [32.2 kB]
Fetched 32.2 kB in 1s (35.5 kB/s)
Selecting previously unselected package atftp.
(Reading database ... 120495 files and directories currently installed.)
Preparing to unpack .../atftp_0.7.git20210915-4build1_amd64.deb ...
Unpacking atftp (0.7.git20210915-4build1) ...
Setting up atftp (0.7.git20210915-4build1) ...
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...
Scanning candidates...
Scanning processor microcode...
Scanning linux images...

The processor microcode seems to be up-to-date.

Restarting services...
Service restarts being deferred:
 systemctl restart NetworkManager.service
 systemctl restart networkd-dispatcher.service
 systemctl restart unattended-upgrades.service

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

atftp にてファイルを取得・送信するコマンド(ワンライナー)

# ルータからファイルを取得
atftp ルータIP -g -r /sample.lua -l /tmp/sample.lua

# ルータへファイルを送信
atftp ルータIP -p -r /sample.lua -l ./sample.lua

atftp 使い方

$ atftp --help
Usage: tftp [options] [host] [port]
 [options] may be:
  -g, --get                : get file
      --mget               : get file using mtftp
  -p, --put                : put file
  -l, --local-file <file>  : local file name
  -r, --remote-file <file> : remote file name
  -P, --password <password>: specify password (Linksys extension)
  --tftp-timeout <value>   : delay before retransmission, client side
  --option <"name value">  : set option name to value
  --mtftp <"name value">   : set mtftp variable to value
  --no-source-port-checking: violate RFC, see man page
  --prevent-sas            : prevent Sorcerer's Apprentice Syndrome
  --verbose                : set verbose mode on
  --trace                  : set trace mode on
  -V, --version            : print version information
  -h, --help               : print this help

 [host] is the tftp server name
 [port] is the port to use