<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ftp on
A Scripter's Notes</title><link>https://scripter.co/categories/ftp/</link><description>Recent content in ftp
on A Scripter's Notes</description><language>en-us</language><managingEditor>kaushal.modi@gmail.com (Kaushal Modi)</managingEditor><webMaster>kaushal.modi@gmail.com (Kaushal Modi)</webMaster><lastBuildDate>Wed, 22 Apr 2026 08:24:58 -0400</lastBuildDate><generator>Hugo -- gohugo.io</generator><docs>https://validator.w3.org/feed/docs/rss2.html</docs><atom:link href="https://scripter.co/categories/ftp/index.xml" rel="self" type="application/rss+xml"/><item><title>Stuff about command-line ftp</title><link>https://scripter.co/stuff-about-command-line-ftp/</link><description>&lt;p>To connect to a machine with ip &lt;em>MACHINE&lt;/em>, you simply need to enter the below at command-line:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">ftp MACHINE
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>See below for a list of commands you would typically use once you &lt;code>ftp&lt;/code> to a machine.&lt;/p>
&lt;h2 id="basic-ftp-commands">Basic FTP Commands&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#basic-ftp-commands">#&lt;/a>&lt;/h2>
&lt;!--- BEGIN RECEIVE ORGTBL ftp-commands -->
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Command&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>?&lt;/code> or &lt;code>help&lt;/code>&lt;/td>
&lt;td>Get help on FTP commands&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>bye&lt;/code> or &lt;code>quit&lt;/code>&lt;/td>
&lt;td>Exit the FTP session&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>binary&lt;/code>&lt;/td>
&lt;td>Set the mode of file transfer to &lt;em>binary&lt;/em>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;/td>
&lt;td>&lt;em>(Provides less chance of transmission error)&lt;/em>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>cd&lt;/code>, &lt;code>ls&lt;/code>, &lt;code>mkdir&lt;/code>, &lt;code>pwd&lt;/code>, &lt;code>rmdir&lt;/code>&lt;/td>
&lt;td>Unix operations on remote machine&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>delete&lt;/code>&lt;/td>
&lt;td>Unix &lt;code>rm&lt;/code> operation on remote machine&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>lcd&lt;/code>&lt;/td>
&lt;td>Unix &lt;code>cd&lt;/code> operation on local machine&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>put&lt;/code> &lt;em>FILE&lt;/em>&lt;/td>
&lt;td>Copy 1 file from local to remote&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>mput&lt;/code> &lt;em>FILES&lt;/em> (ex: &lt;code>mput *&lt;/code>)&lt;/td>
&lt;td>Copy multiple files from local to remote&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>get&lt;/code> &lt;em>FILE&lt;/em>&lt;/td>
&lt;td>Copy 1 file from remote to local&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>mget&lt;/code> &lt;em>FILES&lt;/em> (ex: &lt;code>mget*&lt;/code>)&lt;/td>
&lt;td>Copy multiple files from remote to local&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;!--- END RECEIVE ORGTBL ftp-commands -->
&lt;!---
#+ORGTBL: SEND ftp-commands orgtbl-to-gfm
| Command | Description |
|-------------------------------------+------------------------------------------------|
| `?` or `help` | Get help on FTP commands |
| `bye` or `quit` | Exit the FTP session |
| `binary` | Set the mode of file transfer to *binary* |
| | *(Provides less chance of transmission error)* |
| `cd`, `ls`, `mkdir`, `pwd`, `rmdir` | Unix operations on remote machine |
| `delete` | Unix `rm` operation on remote machine |
| `lcd` | Unix `cd` operation on local machine |
| `put` *FILE* | Copy 1 file from local to remote |
| `mput` *FILES* (ex: `mput *`) | Copy multiple files from local to remote |
| `get` *FILE* | Copy 1 file from remote to local |
| `mget` *FILES* (ex: `mget*`) | Copy multiple files from remote to local |
-->
&lt;h2 id="automating-ftp-logins-for-specific-ips">Automating FTP logins for specific IPs&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#automating-ftp-logins-for-specific-ips">#&lt;/a>&lt;/h2>
&lt;p>If you find yourself logging into a specific &lt;em>MACHINE&lt;/em> too frequently, and if you want to save yourself from having to enter the username and password each time, you can save those credentials to your &lt;code>~/.netrc&lt;/code> file. See the example at the end of this post.&lt;/p>
&lt;p>If that file does not exist, then create it, and &lt;strong>remember to set its permission to 600&lt;/strong>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">touch ~/.netrc
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">chmod &lt;span class="m">600&lt;/span> ~/.netrc
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If the permissions are not set so, you will get this ftp error:&lt;/p>
&lt;pre tabindex="0">&lt;code>Error - .netrc file not correct mode.
Remove password or correct mode.
&lt;/code>&lt;/pre>
&lt;h3 id="ignore-the-credentials-in-netrc">Ignore the credentials in &lt;code>.netrc&lt;/code>&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#ignore-the-credentials-in-netrc">#&lt;/a>&lt;/h3>
&lt;p>But at times, you might need to manually log into a machine with a different set of credentials than the one saved in the &lt;code>~/.netrc&lt;/code>. To do so, run &lt;code>ftp&lt;/code> with the &lt;code>-n&lt;/code> option. And then use the &lt;code>quote USER&lt;/code> and &lt;code>quote PASS&lt;/code> commands to pass in the username and password.&lt;/p>
&lt;pre tabindex="0">&lt;code>&amp;gt; ftp -n &amp;lt;machine&amp;gt;
ftp&amp;gt; quote USER &amp;lt;username&amp;gt;
ftp&amp;gt; quote PASS &amp;lt;password&amp;gt;
&lt;/code>&lt;/pre>
&lt;h3 id="commenting-out-stuff-in-netrc">Commenting out stuff in &lt;code>.netrc&lt;/code>&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#commenting-out-stuff-in-netrc">#&lt;/a>&lt;/h3>
&lt;p>Unfortunately, &lt;code>.netrc&lt;/code> does not seem to have a comment syntax. But this hack works ..&lt;/p>
&lt;p>Using the &lt;code>#&lt;/code> character quickly followed by an FTP command &lt;em>foo&lt;/em> (no space, ex: &lt;code>#foo&lt;/code>) is one way to &amp;ldquo;comment out&amp;rdquo; lines with valid .netrc keywords.&lt;/p>
&lt;blockquote>
&lt;p>You cannot have such &amp;lsquo;comments&amp;rsquo; after valid .netrc keywords are used.&lt;/p>
&lt;/blockquote>
&lt;p>So if you need to comment out a set of logins and passwords, do that &lt;strong>before&lt;/strong> the first valid set of uncommented login credentials. See below for an example of that.&lt;/p>
&lt;h2 id="an-example-netrc">An Example &lt;code>~/.netrc&lt;/code>&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#an-example-netrc">#&lt;/a>&lt;/h2>
&lt;pre tabindex="0">&lt;code>#machine foo.bar.com
#login username1
#password pAsSw0rd1
machine foo.bar.com
login username2
password pAsSw0rd2
&lt;/code>&lt;/pre>
&lt;h2 id="references">References&amp;nbsp;&lt;a class="headline-hash no-text-decoration" href="#references">#&lt;/a>&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.cs.colostate.edu/helpdocs/ftp.html">Basic FTP Commands&lt;/a> - Colorado State Univerity&lt;/li>
&lt;li>&lt;a href="https://unix.stackexchange.com/a/28440/57923">Use configuration file for ftp with auto login enabled upon initial connection&lt;/a> - &lt;em>unix.stackexchange&lt;/em>&lt;/li>
&lt;li>&lt;code>man ftp&lt;/code>, &lt;code>man netrc&lt;/code>&lt;/li>
&lt;/ul></description><category domain="https://scripter.co/categories/ftp">ftp</category><guid>https://scripter.co/stuff-about-command-line-ftp/</guid><pubDate>Thu, 12 Jan 2017 12:07:43 -0500</pubDate></item></channel></rss>