SkillPilotAI

ncftp

NcFTP is a full-featured interactive FTP client that replaces the old stock ftp program, with bookmarks, auto-resume and recursive transfers. It also ships ncftpget, ncftpput and ncftpls, one-line tools for scripts that never prompt and return exit codes.

153.1 Why is it used?

  • Browse an FTP server interactively with bookmarks, so 'open lab' logs in and opens the right folder.
  • Auto-resume: a broken download continues with REST instead of starting again.
  • get -R / put -R move whole folder trees.
  • ncftpget / ncftpput / ncftpls do one transfer in one line and give an exit code for scripts.
  • Install: Linux apt install ncftp (Debian 12: 3.2.6), macOS brew install ncftp, Windows has no native build (use WSL).

153.2 How it works: session and bookmark

  • Lab: client 192.168.173.20 runs ncftp, server lab-ftp 192.168.173.10 runs vsftpd on port 21.
  • ncftp sends USER/PASS on port 21; the server replies Login successful.
  • bookmark NAME saves host + folder + login in ~/.ncftp/bookmarks.
ncftp login and bookmark
  1. 1.Client 192.168.173.20 runs: ncftp, open -u student -p lab123 lab-ftp

  2. 2.USER / PASS go through the lab switch to 192.168.173.10:21

  3. 3.Server: Login successful.

  4. 4.cd pub, then: bookmark lab

  5. 5.Client saves host + dir + login in ~/.ncftp/bookmarks

  6. 6.Next time: open lab -> logs in and lands in /pub

153.3 Command-line usage

  • ncftp -u USER -p PASS host logs in; pwd shows the location as a URL with the password hidden.
  • ncftp ftp://host/dir/ logs in as anonymous and goes straight into that folder.
  • A bookmark name also works in place of a host name.
Terminal
ncftp -u student -p lab123 lab-ftp  pwd  ls  quitncftp ftp://lab-ftp/pub/  ls  quit
Output
$ ncftp ftp://lab-ftp/pub/n153 lab FTP serverLogin successful.Logged in to lab-ftp.Current remote directory is /pub.ncftp /pub > lsreadme.txt
Option / formMeaning
ncftp hostOpen host (anonymous)
ncftp ftp://h/dir/Open + cd into that dir
-u aliceLog in as user alice
-p Secr3tPassword for that user
-j acct1Account (deprecated)
-P 2121Port 2121 instead of 21
ncftp mybookmarkBookmark instead of host

153.4 Script tools: ncftpget, ncftpput, ncftpls

  • ncftpget host LOCAL-dir REMOTE-file: local folder first, then remote file.
  • ncftpput host REMOTE-dir LOCAL-files: order reversed, remote folder first.
  • ncftpls -l URL gives a long listing.
  • Exit codes seen in the lab: 1 = login failed, 3 = remote file not found.
Terminal
cd /tmp/w/clincftpget -u student -p lab123 lab-ftp \  . /report.txtncftpput -u student -p lab123 lab-ftp \  /incoming upload.txtncftpls -l \  ftp://student:lab123@lab-ftp/incoming/ncftpget -u student -p wrongpass lab-ftp \  . /report.txt; echo rc=$?ncftpget -u student -p lab123 lab-ftp \  . /nosuch.txt; echo rc=$?
Output
$ ncftpls -l ftp://student:lab123@lab-ftp/incoming/-rw-r--r--    1 1000     1000           21 Nov 09 06:08 upload.txt$ ncftp -u student -p wrongpass lab-ftpn153 lab FTP serverLogin incorrect.Could not open host lab-ftp: username and/or password was not accepted for login.ncftp>

153.5 Interactive session: open, bookmark, lookup, debug

  • Start ncftp with no host, then open -u -p; close disconnects but stays at ncftp>; quit/bye/exit leave.
  • bookmarks -l lists saved bookmarks; open lab reconnects using one.
  • lookup host resolves names; lookup -v IP does a detailed reverse lookup (it returned the Docker container name).
  • debug 1 shows protocol commands (PASV, LIST, 227, 226); debug info always goes to the trace file too.
  • version prints the NcFTP and library versions.
Terminal
ncftpset pager catset save-passwords yesopen -u student -p lab123 lab-ftpcd pubbookmark labclosebookmarks -llookup lab-ftplookup -v 192.168.173.10open labdebug 1lsdebug 0version
Output
ncftp> open labConnecting to 192.168.173.10...Login successful.Logged in to lab-ftp.Directory successfully changed.Current remote directory is /pub.ncftp /pub > versionVersion:          NcFTP 3.2.6/575 Dec 04 2016, 01:00 PMLibrary Version:  LibNcFTP 3.2.6 (November 12, 2016)Compile Date:     Jul 27 2022Platform:         linux-x86_64-glibc2.33

153.6 Remote navigation and listing

  • ls = short listing (ls -CF, slash after folders); dir = detailed (ls -l); both accept Unix ls flags like -rt.
  • cd - goes back to the previous remote folder; pwd shows the current one.
  • pls / pdir send the listing to the pager; cat prints a remote file, page shows it in the pager.
Output
ncftp / > cd pub/newsDirectory successfully changed.ncftp /pub/news > cat today.txtncftp release todayncftp /pub/news > cd /nosuchCould not chdir to /nosuch: server said: Failed to change directory.

153.7 Downloading: get

  • get README report.txt downloads several files; wildcards work like mget.
  • get -z remote local saves under a different local name; -a uses ASCII mode (CR LF becomes LF).
  • With auto-resume yes, a partial file continues with REST; -f downloads the whole file again.
  • If the local file is the same, ncftp says the download is not necessary.
  • get -R -T dir: whole tree, without TAR mode so it can resume.
Auto-resume with REST
  1. 1.Local big.iso has 500000 of 2000000 bytes (download broke)

  2. 2.ncftp checks the remote size with SIZE

  3. 3.Client sends REST 500000

  4. 4.Server: 350 Restart position accepted (500000).

  5. 5.Only the remaining 1500000 bytes come on the data connection

  6. 6.big.iso: 2000000 bytes

Terminal
ncftp -u student -p lab123 lab-ftpset auto-resume yesget README report.txtget -z win.dat win-bin.datget -a -z win.dat win-ascii.datdebug 1get /isos/big.isodebug 0get -f /isos/big.isoget /isos/big.isoget -R -T isosget nosuch.txt
Output
$ od -c win-bin.dat | head -20000000   m   o   d   e   =   p   r   o   d  \r  \n   p   o   r   t   =$ od -c win-ascii.dat | head -20000000   m   o   d   e   =   p   r   o   d  \n   p   o   r   t   =   8ncftp / > get -f /isos/big.isobig.iso:                                                 1.91 MB   71.11 MB/sncftp / > get /isos/big.isoget /isos/big.iso: local file appears to be the same as the remote file, download is not necessary.ncftp / > get nosuch.txtget nosuch.txt: server said: Failed to open file.

153.8 Uploading: put

  • put a.zip b.zip uploads several files; put -z local remote gives a new remote name.
  • put -R site uploads a whole folder; put -f overwrites without resume.
  • A missing local file gives 'Cannot open local file'.
Output
ncftp /incoming > put nosuch.zipCannot open local file nosuch.zip for reading: No such file or directory.put nosuch.zip: could not open file.ncftp /incoming > dir-rw-r--r--    1 1000     1000            5 Nov  9 06:08 a.zip-rw-r--r--    1 1000     1000            5 Nov  9 06:08 b.zip-rw-r--r--    1 1000     1000            9 Nov  9 06:08 report-2026.csvdrwxr-sr-x    3 1000     1000         4096 Nov  9 06:08 site-rw-r--r--    1 1000     1000           21 Nov  9 06:08 upload.txt
Flaggetput
-zDifferent local nameDifferent remote name
-fNo resume, whole fileNo resume, overwrite
-AAppend to local fileAppend to remote file
-DDDelete remote file on successDelete local file on success
-RWhole remote treeWhole local tree
-aASCII mode-
bgget / bgputBackground queue (ncftpbatch)Background queue (ncftpbatch)
-@ 20261106030000Schedule for a timeSchedule for a time

153.9 Remote file management and protocol commands

  • mkdir, rmdir (empty only), rm (no -rf), rename, chmod (uses SITE CHMOD), umask (SITE UMASK).
  • edit downloads a file, opens a local editor, uploads it back.
  • quote sends a raw FTP command (quote STAT); site sends a SITE command; site help / rhelp list server commands.
  • Transfer type: binary is default (type image = type i); ascii only for text files.
Output
ncftp / > site helpCHMOD UMASK HELPncftp / > rhelpThe following commands are recognized. ABOR ACCT ALLO APPE CDUP CWD  DELE EPRT EPSV FEAT HELP LIST MDTM MKD MODE NLST NOOP OPTS PASS PASV PORT PWD  QUIT REIN REST RETR RMD  RNFR RNTO SITE SIZE SMNT STAT STOR STOU STRU SYST TYPE USER XCUP XCWD XMKD XPWD XRMDHelp OK.

153.10 Local commands

  • l-commands act on the client machine and do not change the remote prompt: lcd, lpwd, lls, lmkdir, lrmdir, lrename, lrm, lchmod, lpage.
  • ! runs a local shell command.
Terminal
lpwdlcd loclls -llmkdir backupslrename old.txt old.baklrm old.baklchmod 600 key.pemlrmdir backups! ls -l /tmp/w/loc

153.11 Variables and environment

  • show all lists every variable; set changes one; values are saved in ~/.ncftp/prefs_v3.
  • passive on|off|optional (optional is default: ncftp chooses PASV or PORT).
  • Timeouts: connect-timeout 20, control-timeout 60, xfer-timeout 600 (seconds).
  • ~/.ncftp holds bookmarks, prefs, log and trace (debug of the last session).
  • NCFTPDIR changes the config folder; PAGER sets the pager; COLUMNS changes ls width.
Output
$ grep -E '^(anon-password|passive|...)=' ~/.ncftp/prefs_v3anon-password=devnull@example.comauto-resume=yesconfirm-close=noconnect-timeout=10logsize=0passive=onsave-passwords=yes

153.12 Common mistakes

  • Mixing up argument order: ncftpget = local then remote, ncftpput = remote then local.
  • Believing bookmark passwords are encrypted: '*encoded*bGFiMTIz' is just base64 and decodes to lab123.
  • Using get -DD / put -DD carelessly: they delete the source after transfer.
  • Downloading text files in binary when line endings matter (use -a).
Output
$ cat ~/.ncftp/bookmarkslab,lab-ftp,student,*encoded*bGFiMTIz,,pub,I,21,1794204513,...$ echo bGFiMTIz | base64 -dlab123

153.13 Interview tips

  • ncftp = interactive browser (bookmarks, auto-resume, -R); ncftpget/ncftpput = one line, no prompt, exit code.
  • Exit codes: 1 = login failed, 3 = file not found.
  • Resume works through the FTP REST command after a SIZE check.
  • Plain FTP and base64 bookmark passwords are not secure: use SFTP for sensitive data.