ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SFTP Question/s?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SFTP Question/s?

    Hi,
    I need to extract the file from SFTP server and load it into AS400 structured file. So far I could manually do it by downloading the file to PC and then uploading it directly to AS400 structured file.

    I need to create batch program to do this.

    1. Can we directly load the SFTP server file to AS400 file ?
    2. Can we dynamically create the FTP script file and then copy it to IFS as .txt file for SFTP to use it as command file?
    I need to do this using CL program.


    Any suggestions/solutions , please let me know.

  • #2
    Re: SFTP Question/s?

    1) yes and no. yes you can, but you need a few extra lic programs. we opted for WSFTP as it was great and cheaper than getting the lics. http://www.ipswitchft.com/products/w...1&k_id=ipshome
    2) You can run the FTP from any member, ie commands log ins, but you still need the lic programs on the 400 to talk to another SFTP server.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: SFTP Question/s?

      IBM provides both FTP over SSL (often referred to as 'ftps', but sometimes people say 'sftp'). They also provide the OpenSSH suite of tools, which includes the FTP-like interface to SSH that's named 'sftp'. Both of these are included at no charge with the operating system. However, they are optional components, so they might not be installed if you haven't installed them already.

      Of the two, I highly recommend OpenSSH with digital keys. It's more secure, and works better through firewalls.

      Either of these can be scripted. In both cases the scripts can be built on-the-fly if you like. My recommendation would be to download the file into the IFS, and then use a tool like CPYFRMIMPF or CPYFRMSTMF to convert it to a physical file.

      (I'm assuming when you use the phrase "AS400 structured file" you actually mean an externally-defined physical file, aka "database table".)

      Comment


      • #4
        Re: SFTP Question/s?

        Cool, I read the ibm site wrong when I needed to do SFTP. Thanks for the correction.
        Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

        Comment


        • #5
          Re: SFTP Question/s?

          Originally posted by Scott Klement View Post
          IBM provides both FTP over SSL (often referred to as 'ftps', but sometimes people say 'sftp'). They also provide the OpenSSH suite of tools, which includes the FTP-like interface to SSH that's named 'sftp'. Both of these are included at no charge with the operating system. However, they are optional components, so they might not be installed if you haven't installed them already.

          Of the two, I highly recommend OpenSSH with digital keys. It's more secure, and works better through firewalls.
          Yes I will be using SFTP for sure and all required tools are already available on iseries.
          Originally posted by Scott Klement View Post
          Either of these can be scripted. In both cases the scripts can be built on-the-fly if you like. My recommendation would be to download the file into the IFS, and then use a tool like CPYFRMIMPF or CPYFRMSTMF to convert it to a physical file.

          (I'm assuming when you use the phrase "AS400 structured file" you actually mean an externally-defined physical file, aka "database table".)
          In fact CPYFRMIMPF and CPYFRMSTMF are much convinient options, but since we started off with no change in the file format and tested it already, it is more on the direct load to "AS400 structured file" meaning externally-defined PF. BTW, i was able to create script on the fly. I will test this and post the outcome of the test.

          Thanks to everyone for their suggestions

          Comment


          • #6
            Re: SFTP Question/s?

            Hi Again, Before moving ahead I have sent the public key to interface.
            They have installed it and when I ran the command -
            ssh -T interfaceid@interface.com

            It did not take continue processing and asked for password. It failed and gave authentication error. Now when I tried again it gave another error - Public Key authentication failed.

            Can someone please suggest whats wrong in set up. I see the Known_hosts file has the entry now for this new server.

            I am trying to set up SFTP for the first time

            Thanks again!

            Comment


            • #7
              Re: SFTP Question/s?

              The trouble is, ssh will only accept password input from a Unix terminal. It will not accept password input from a script or from a 5250 terminal (since it's Unix software, it doesn't know about 5250 terminals, and just assumes they aren't actually terminals.)

              so, if you want to use password authentication, you'll need to:
              1. Set up the SSHD on IBM i (which is really simple to do) and connect to it using a Unix-compatible terminal (such as Putty, which is free.)
              2. Or, use a tool like Expect that's smart enough to emulate a Unix terminal when running a script.


              Also, I'm a bit confused by the -T option. Why are you passing that? Won't that disable tty allocation?

              If it helps, I've written a bunch of articlss about this (though, there are some errors in them) and I present on this topic at user groups, etc. You can check out my articles and stuff here:


              And the handout from my talks (which is more up-to-date) here:

              Comment


              • #8
                Re: SFTP Question/s?

                On Side note you started with SFTP and are now talking about SSH. You do not need SSH to do SFTP. I never did. I just connected with SFTP to the port and traded / accepted the cert.
                Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                Comment


                • #9
                  Re: SFTP Question/s?

                  @DeadManWalks: Please read post #3 in this thread, where I explain the difference between "ftps" (FTP over SSL) and "sftp" (FTP-like interface to SSH)

                  Unless I'm misunderstanding what you mean by "sftp", you do indeed need OpenSSH for sftp. (But, it's free and included with the OS, so don't let that stop works.)

                  Comment


                  • #10
                    Re: SFTP Question/s?

                    Thank you very Much Scott. Its been good learning for me to set up new SFTP.

                    All good now. I am able to connect to SFTP server from AS400 after having public key on the both server/clients.

                    AS mentioned earlier, I was suspicious abt the direct load to AS400 file. It did not work. But I could load that object to IFS link successfully. I will check for the options available to load this file and post the final result.


                    Thank you very much for you help.

                    Comment


                    • #11
                      Re: SFTP Question/s?

                      Originally posted by swaps400 View Post
                      AS mentioned earlier, I was suspicious abt the direct load to AS400 file. It did not work. But I could load that object to IFS link successfully. I will check for the options available to load this file and post the final result.
                      I suggested earlier that you use CPYTOIMPF or CPYTOSTMF. You seemed to like that suggestion, you said this was a convenient option. So, I guess I'm not sure what you're asking?

                      The SFTP tool is a Unix program. IT does not understand how to read/write physical files (which are really database tables, not 'files' in the sense that Unix systems think of them). Though, IBM's IFS layer may be smart enough to make them work sufficiently for you -- but personally, I'd opt for a more flexible solution, and use something like CPYTOIMPF or CPYTOSTMF to convert them.

                      Comment


                      • #12
                        Re: SFTP Question/s?

                        Originally posted by Scott Klement View Post
                        I suggested earlier that you use CPYTOIMPF or CPYTOSTMF. You seemed to like that suggestion, you said this was a convenient option. So, I guess I'm not sure what you're asking?
                        Thank you Scott.... I am also in favor of using CPYTOIMPF and CPYTOSTMF. Actually this process was in FTP and was working well. So interface partner just used the same method and u know there are always other decion making factors which asked to keep the same format.

                        Anyway... it added to our task to load object from IFS to AS400 File. It worked now with another added step of FTP which FTP on the same system from IFS to AS400 file. I know its little annoying solution

                        Thank you again as it was first SFTP and worked well now. I hope in future I can make more in way we discussed

                        Comment


                        • #13
                          Re: SFTP Question/s?

                          Originally posted by Scott Klement View Post
                          The trouble is, ssh will only accept password input from a Unix terminal. It will not accept password input from a script or from a 5250 terminal (since it's Unix software, it doesn't know about 5250 terminals, and just assumes they aren't actually terminals.)

                          so, if you want to use password authentication, you'll need to:
                          1. Set up the SSHD on IBM i (which is really simple to do) and connect to it using a Unix-compatible terminal (such as Putty, which is free.)
                          2. Or, use a tool like Expect that's smart enough to emulate a Unix terminal when running a script.


                          Also, I'm a bit confused by the -T option. Why are you passing that? Won't that disable tty allocation?

                          If it helps, I've written a bunch of articlss about this (though, there are some errors in them) and I present on this topic at user groups, etc. You can check out my articles and stuff here:


                          And the handout from my talks (which is more up-to-date) here:
                          http://www.scottklement.com/presentations
                          There is an easier and cleaner way with dealing password authentication. We offer a free tool called ARP-SFTP that supports password authentication, key based authentication and both password and key. You don't need to become a unix expert and you will be running in minutes. You can download a free version at www.arpeggiosoftware.com/arpsftp.

                          Rich

                          Comment

                          Working...
                          X