<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SFTP using expect script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581464#M733355</link>
    <description>Below the very basic script I have made:&lt;BR /&gt;#!/usr/bin/expect&lt;BR /&gt;set argc [llength $argv]&lt;BR /&gt;set host_id [lindex $argv 0]&lt;BR /&gt;set user_id [lindex $argv 1]&lt;BR /&gt;set Password [lindex $argv 2]&lt;BR /&gt;set remote_file_s_ [lindex $argv 3]&lt;BR /&gt;set local_directory [lindex $argv 4]&lt;BR /&gt;&lt;BR /&gt;spawn /usr/bin/sftp $user_id@$host_id&lt;BR /&gt;expect "password:"&lt;BR /&gt;send "$Password\n"&lt;BR /&gt;expect "sftp&amp;gt;"&lt;BR /&gt;send "get $remote_file_s_ $local_directory\n"&lt;BR /&gt;expect "sftp&amp;gt;"&lt;BR /&gt;send "quit\n"&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;My questions: &lt;BR /&gt;How can I return potential errors to the calling process?&lt;BR /&gt;Is there a book with comprehensive examples to create state of the art script?&lt;BR /&gt;&lt;BR /&gt;Thanks per advance for your help and support.</description>
    <pubDate>Wed, 10 Feb 2010 16:10:49 GMT</pubDate>
    <dc:creator>Gerard Schrago</dc:creator>
    <dc:date>2010-02-10T16:10:49Z</dc:date>
    <item>
      <title>SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581464#M733355</link>
      <description>Below the very basic script I have made:&lt;BR /&gt;#!/usr/bin/expect&lt;BR /&gt;set argc [llength $argv]&lt;BR /&gt;set host_id [lindex $argv 0]&lt;BR /&gt;set user_id [lindex $argv 1]&lt;BR /&gt;set Password [lindex $argv 2]&lt;BR /&gt;set remote_file_s_ [lindex $argv 3]&lt;BR /&gt;set local_directory [lindex $argv 4]&lt;BR /&gt;&lt;BR /&gt;spawn /usr/bin/sftp $user_id@$host_id&lt;BR /&gt;expect "password:"&lt;BR /&gt;send "$Password\n"&lt;BR /&gt;expect "sftp&amp;gt;"&lt;BR /&gt;send "get $remote_file_s_ $local_directory\n"&lt;BR /&gt;expect "sftp&amp;gt;"&lt;BR /&gt;send "quit\n"&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;My questions: &lt;BR /&gt;How can I return potential errors to the calling process?&lt;BR /&gt;Is there a book with comprehensive examples to create state of the art script?&lt;BR /&gt;&lt;BR /&gt;Thanks per advance for your help and support.</description>
      <pubDate>Wed, 10 Feb 2010 16:10:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581464#M733355</guid>
      <dc:creator>Gerard Schrago</dc:creator>
      <dc:date>2010-02-10T16:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581465#M733356</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Normal shell scripts have a variable set with return code for every line of code they execute:&lt;BR /&gt;&lt;BR /&gt;$?&lt;BR /&gt;&lt;BR /&gt;echo steve&lt;BR /&gt;rc=$?&lt;BR /&gt;return $rc&lt;BR /&gt;&lt;BR /&gt;Returns the error code.&lt;BR /&gt;&lt;BR /&gt;I'm wondering why sftp is being used. scp with password free connection can move these files without a complex expect script.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/?p=10" target="_blank"&gt;http://www.hpux.ws/?p=10&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 10 Feb 2010 16:36:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581465#M733356</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2010-02-10T16:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581466#M733357</link>
      <description>Hello Gerard,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Is there a book with comprehensive examples to create state of the art script?&lt;BR /&gt;&lt;BR /&gt;You can study the examples that came with expect.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://expect.nist.gov/#examples" target="_blank"&gt;http://expect.nist.gov/#examples&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Horia.</description>
      <pubDate>Thu, 11 Feb 2010 06:02:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581466#M733357</guid>
      <dc:creator>Horia Chirculescu</dc:creator>
      <dc:date>2010-02-11T06:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581467#M733358</link>
      <description>Thanks to both of you.&lt;BR /&gt;Steven, I wish I could use scp but I am bound to use SFTP; this is CIO decision and customer policy. Allthough we are passing over private network, DMZ, etc. we have to be securer than secure ;-)&lt;BR /&gt;Thanks and best regards.&lt;BR /&gt;GÃ©rard.</description>
      <pubDate>Thu, 11 Feb 2010 16:07:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581467#M733358</guid>
      <dc:creator>Gerard Schrago</dc:creator>
      <dc:date>2010-02-11T16:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581468#M733359</link>
      <description>Gerard.&lt;BR /&gt;&lt;BR /&gt;sftp and scp are both part of the SecureShell protocols.  The only difference here is the ease of scripting something.&lt;BR /&gt;By using the SSH protocols and setting up keys on both sides, you provide a secure method for transferring data *encrypted* between sites without passwords.  &lt;BR /&gt;&lt;BR /&gt;One of the MOST unsecure things you could do is put the password in plain text in a file, which is exactly what your script will do. Since mgmt obviously is seeking a safety and security of data transfer, you might want to point this fact out to them.  Fact is, one of the biggest and hardest to control security threats is 'inside your shop'.  And putting passwords in files - very bad!&lt;BR /&gt;&lt;BR /&gt;Stephen told you well, you need to keep your data secure.  And sometimes you have to teach the right way to do that to managers.&lt;BR /&gt;&lt;BR /&gt;Just my 2cents,&lt;BR /&gt;Rita</description>
      <pubDate>Thu, 11 Feb 2010 18:12:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581468#M733359</guid>
      <dc:creator>Rita C Workman</dc:creator>
      <dc:date>2010-02-11T18:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581469#M733360</link>
      <description>&lt;!--!*#--&gt;&amp;gt; [...] I wish I could use scp but I am bound&lt;BR /&gt;&amp;gt; to use SFTP [...]&lt;BR /&gt;&lt;BR /&gt;What does the "s" in "scp" stand for?&lt;BR /&gt;What does the "s" in "sftp" stand for?&lt;BR /&gt;What's the difference in the underlying&lt;BR /&gt;encryption software?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; this is CIO decision and customer policy.&lt;BR /&gt;&lt;BR /&gt;Why?  (When asking why, try asking the&lt;BR /&gt;questions above.)&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] sometimes you have to teach [...]&lt;BR /&gt;&lt;BR /&gt;Or try, at least.  Or try to get a reason&lt;BR /&gt;which makes more sense than none at all.</description>
      <pubDate>Thu, 11 Feb 2010 20:20:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581469#M733360</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-02-11T20:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581470#M733361</link>
      <description>I concur, Gerard.&lt;BR /&gt;&lt;BR /&gt;This sort of thing is exactly what Secure Shell public key authentication was designed for, and it shouldn't be hard to make a case to take that approach, and you can use it either on SCP or SFTP - they use the same underlying protocol after all.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://ask-leo.com/how_can_i_automate_an_sftp_transfer_between_two_servers.html" target="_blank"&gt;http://ask-leo.com/how_can_i_automate_an_sftp_transfer_between_two_servers.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You can even lock down the authorized_keys so that the key  you use for the file transfer can not be used to connect from any other host but the one you're using to fetch the file (from=fetch-host.you.com), and also make it impossible for the key to be used to start a shell (no-pty).&lt;BR /&gt;&lt;BR /&gt;When you lock down the permissions of the password-less private key to 400 for the userid that will be using it, then you'll have a number of layers of security at work, and no plaintext password sitting in a script file.&lt;BR /&gt;&lt;BR /&gt;See also &lt;A href="http://www.eng.cam.ac.uk/help/jpmg/ssh/authorized_keys_howto.html" target="_blank"&gt;http://www.eng.cam.ac.uk/help/jpmg/ssh/authorized_keys_howto.html&lt;/A&gt; for a decent discussion of the subject.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Feb 2010 22:08:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581470#M733361</guid>
      <dc:creator>mvpel</dc:creator>
      <dc:date>2010-02-11T22:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581471#M733362</link>
      <description>Dear all,&lt;BR /&gt;&lt;BR /&gt;scp versus sftp: scp also require a password prior any transfer unless you specify -B option and then it is still refused with the rply : Permission denied (publickey,gssapi-with-mic,password) which lead to other administrative burden.&lt;BR /&gt;That's why I have to stick to the imposed SFTP. Regarding confidentiality it is preserved since the password is passed as an argument by the calling process (a compiled LISP process running on Linux).&lt;BR /&gt;With my best regards.</description>
      <pubDate>Fri, 12 Feb 2010 08:47:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581471#M733362</guid>
      <dc:creator>Gerard Schrago</dc:creator>
      <dc:date>2010-02-12T08:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581472#M733363</link>
      <description>Hi Gerard:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Regarding confidentiality it is preserved since the password is passed as an argument by the calling process&lt;BR /&gt;&lt;BR /&gt;That's not preserving the password's knowledge.  A simple 'ps' can expose the arguments passed to the process.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 12 Feb 2010 12:40:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581472#M733363</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-02-12T12:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581473#M733364</link>
      <description>Gerard,&lt;BR /&gt;&lt;BR /&gt;I think you are missing the point.  I know it was a learning experience for me the first time I started using it too.&lt;BR /&gt;&lt;BR /&gt;As part of SSH protocols you generate a 'key' (man ssh-keygen).  It actually creates two files, one is a .pub (public) key and the other is considered the private key.&lt;BR /&gt;You send the public key to the remote server and the file in properly inserted on that system.  Albeit under the boxes account /home/dirpath/.ssh or on other platforms or third party vendors it might be added to a database.  In any event the remote server sets-up this 'key' file.&lt;BR /&gt;&lt;BR /&gt;Then from the first/primary server you connect to the remote server and make the initial connection.  In the background the systems 'shake-hands' so to speak and recognize that both sides have the same keys.  Systems are happy and acknowledge each other.  &lt;BR /&gt;&lt;BR /&gt;NOW....when your primary server wants to connect next time....NO PASSWORD REQUIRED.&lt;BR /&gt;Hence, your local script does not require the password to be part of the syntax.&lt;BR /&gt;&lt;BR /&gt;scp &lt;THIS file=""&gt; &lt;REMOVE-LOGIN-ID&gt;@&lt;REMOTESERVER&gt;:/dir/path&lt;BR /&gt;&lt;BR /&gt;Piece of cake !&lt;BR /&gt;Encrypted, password-less and secure.&lt;BR /&gt;Both using the SSH protocols.&lt;BR /&gt;&lt;BR /&gt;Kindest regards &amp;amp; hope this makes some sense,&lt;BR /&gt;Rita&lt;/REMOTESERVER&gt;&lt;/REMOVE-LOGIN-ID&gt;&lt;/THIS&gt;</description>
      <pubDate>Fri, 12 Feb 2010 18:47:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581473#M733364</guid>
      <dc:creator>Rita C Workman</dc:creator>
      <dc:date>2010-02-12T18:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: SFTP using expect script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581474#M733365</link>
      <description>Gerard,&lt;BR /&gt;I know your pain. I work in a bank and just finshed a huge project. We have around 100 servers which all interace with each other. Servers are scattered through out internal LAN, and DMZ. It was orginally 2 of us and 1 day into the project my colleague was pulled into another one.&lt;BR /&gt;&lt;BR /&gt;We were required (from our CIO as well) to remove any FTP scripts,.netrc, clear text pw, etc.&lt;BR /&gt;I implemented SFTP communicating from UNIX to UNIX, and UNIX to Windows...vice versa.&lt;BR /&gt;&lt;BR /&gt;Feel free to contact me regarding any questions you may have.</description>
      <pubDate>Sat, 13 Feb 2010 03:13:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sftp-using-expect-script/m-p/4581474#M733365</guid>
      <dc:creator>Chris Campbell 77</dc:creator>
      <dc:date>2010-02-13T03:13:31Z</dc:date>
    </item>
  </channel>
</rss>

