<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: scp code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 26 Jul 2008 11:12:39 GMT</pubDate>
    <description>DZone Snippets: scp code</description>
    <item>
      <title>SCP Secure CP</title>
      <link>http://snippets.dzone.com/posts/show/5498</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Scp is a utility which allows files to be copied between machines. Scp is an updated version of an older utility named Rcp. It works the same, except that information (including the password used to log in) is encrypted. Also, if you have set up your .shosts file to allow you to ssh between machines without using a password as described in help on setting up your .shosts file, you will be able to scp files between machines without entering your password.&lt;br /&gt;Usage of the Scp Command&lt;br /&gt;&lt;br /&gt;The general form of the command is:&lt;br /&gt;&lt;br /&gt;	% scp source-specification destination-specification&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;where source-specification indicates which file or directory is to be copied, and destination-specification indicates where the copied material is to be placed.&lt;br /&gt;&lt;br /&gt;Either the source or the destination may be on the remote machine; i.e., you may copy files or directories into the account on the remote system OR copy them from the account on the remote system into the account you are logged into.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;	% scp myfile xyz@sdcc7:myfile&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;To copy a directory, use the -r (recursive) option. Example:&lt;br /&gt;&lt;br /&gt;	% scp -r mydir xyz@sdcc7:mydir&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;File Specification Formats&lt;br /&gt;&lt;br /&gt;The format for the remote specification (source or destination) is:&lt;br /&gt;&lt;br /&gt;	user@machine:filename&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;where filename is the name (path) of the file or directory relative to the home (login) directory on the remote system.&lt;br /&gt;&lt;br /&gt;The format for file specification on the local system is just:&lt;br /&gt;&lt;br /&gt;	filename&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;where fname is the name (path) relative to the current working directory on that system.&lt;br /&gt;How scp is similar to cp&lt;br /&gt;&lt;br /&gt;Just like the cp command, scp will overwrite an existing destination file. In addition, if the destination is an existing directory, the copied material will be placed beneath the directory.&lt;br /&gt;Examples of remote file copies&lt;br /&gt;&lt;br /&gt;   1. While logged into xyz on sdcc7, copy file "letter" into file "application" in remote account abc on sdcc3:&lt;br /&gt;&lt;br /&gt;      	% scp letter abc@sdcc3:application&lt;br /&gt;      	&lt;br /&gt;&lt;br /&gt;   2. While logged into abc on sdcc3, copy file "foo" from remote account xyz on sdcc7 into filename "bar" in abc:&lt;br /&gt;&lt;br /&gt;      	% scp xyz@sdcc7:foo bar&lt;br /&gt;&lt;br /&gt;      	&lt;br /&gt;&lt;br /&gt;   3. While logged into account xyz on sdcc7, copy file "garfield" from subdirectory "comix" into filename "fatcat" in subdirectory "stuff" in remote account abc on sdcc3:&lt;br /&gt;&lt;br /&gt;      	% scp comix/garfield abc@sdcc3:stuff/fatcat&lt;br /&gt;      	&lt;br /&gt;&lt;br /&gt;   4. While logged into account abc on sdcc3, copy file "garfield" from subdirectory "comix" of account xyz on sdcc7 into subdirectory "stuff" with the same name "garfield":&lt;br /&gt;&lt;br /&gt;      	% scp xyz@sdcc7:comix/garfield stuff&lt;br /&gt;      	&lt;br /&gt;&lt;br /&gt;   5. While logged into account abc on sdcc3 , copy subdirectory "Section" into a new subdirectory called "Section" in existing subdirectory "Chapter" in account xyz on sdcc7:&lt;br /&gt;&lt;br /&gt;      	% scp -r Section xyz@sdcc7:Chapter&lt;br /&gt;      	&lt;br /&gt;&lt;br /&gt;   6. From account abc on sdcc3, copy entire account to ir123 on iacs5. This needs to be done from the parent directory of the account to be moved.&lt;br /&gt;&lt;br /&gt;      	% cd&lt;br /&gt;      	% cd ..&lt;br /&gt;      	% scp -r abc ir123@iacs5:abc&lt;br /&gt;      	&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 15 May 2008 20:32:23 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5498</guid>
      <author>fedorafred (Fred)</author>
    </item>
    <item>
      <title>Copy Public Key To Host In One Line</title>
      <link>http://snippets.dzone.com/posts/show/5258</link>
      <description>&lt;code&gt;&lt;br /&gt;ssh username@host "echo `cat ~/.ssh/id_dsa.pub` &gt;&gt; ~/.ssh/authorized_keys"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 19 Mar 2008 18:23:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5258</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>ssh and scp without typing a password each time</title>
      <link>http://snippets.dzone.com/posts/show/2700</link>
      <description>* You can create and exchange ssh keys to avoid repeatedly typing your password.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Source:      ssh-keygen -t dsa                                     Type this once per log-in session&lt;br /&gt;Source:      Now copy the .ssh/id_dsa.pub file to &lt;Destination&gt;.&lt;br /&gt;Source:      scp .ssh/id_dsa.pub userid@&lt;Destination&gt;:tempid        we've renamed it tempid.&lt;br /&gt;Destination: cat tempid &gt;&gt; .ssh/authorized_keys                     &lt;br /&gt;add the contents of tempid to .ssh/authorized_keys.&lt;br /&gt;Destination: rm tempid. &lt;br /&gt;&lt;/pre&gt;</description>
      <pubDate>Sat, 23 Sep 2006 18:33:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2700</guid>
      <author>nevadalife (nevada)</author>
    </item>
    <item>
      <title>SSH Key Pairs Stuff</title>
      <link>http://snippets.dzone.com/posts/show/2478</link>
      <description>//allows for copying of ssh keys&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ssh-keygen -t dsa&lt;br /&gt;ssh user@host 'cat &gt;&gt; .ssh/authorizedkeys' &lt; .ssh/id_dsa.pub&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 27 Aug 2006 22:47:31 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2478</guid>
      <author>jnunemaker ()</author>
    </item>
  </channel>
</rss>
