ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Receiving files through sftp.

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

  • Receiving files through sftp.

    Hello everyone

    I need to get some files stored aat a remote server into my system through sftp. The files are multiple but all start with a generic name .How do i approach this.

    Just need a general way of how you would approach it.

    Also i dont know why lsoutput is used for.

  • #2
    Re: Receiving files through sftp.

    More Info:

    I?m pretty handy using sFTP. I?ve configured sFTP several times on IBM i and am able to securely send and receive (put and get) data from the i to a remote system. And I?m talking Secure File Transfer Protocol (or SSH File Transfer Protocol), not FTP through Secure Sockets Layer or SSL FTP. sFTP is the widely used protocol for transferring information securely?especially with financial institutions like banks and credit-card companies. Note that sFTP runs under the Portable Application Solutions Environment (PASE), the UNIX runtime within i. Licensed program 5733-SC1 (Portable Utilities for i) contains OpenSSH, the open-source implementation of Secure Shell. You also need i Option 33?PASE to be installed on your system.
    I usually follow the same general steps when configuring sFTP to be used in a batch process. These steps are to configure sFTP without a password. Most financial institutions I?ve worked with have used this method. You can use sFTP with a password, but you?d need something like a TCP expect script, which makes the process more complicated.
    sFTP uses public-key encryption, meaning each side (your system and the remote system) will create a public encryption key and send it to the other. Each side can then encrypt information with the partner?s public key. I?ll show a basic sFTP setup, and discuss a few potential problems and how to avoid them.
    PHP Code:
    sFTP Configuration Basics

    First
    sign on as the user that will perform the batch sFTPI?ll use SFTPUSER in this exampleStart configuring sFTP by issuing CALL QP2TERM to start an i PASE sessionwhich provides a PASE command linePerform the following steps by entering commands on the command line:

    1. Create a /home directory for the user that will be running sFTP (the user the batch process runs under). If the user already has a /home directoryyou can skip this step. If not, use command mkdir home/SFTPUSERwhere SFTPUSER is the specified user.

    Ensure the permissions are set correctly on the /home directoryThis is one of the gotchas with sFTP. If these permissions are incorrectsFTP won?t work and it?s difficult to find the causeIssue the change mode (chmodcommand to set the /home directory?s permissions:

    chmod 755 /home/SFTPUSER

    2. Generate the 
    public and private encryption keys using the ssh-keygen command:

    ssh-keygen -t dsa -""

    You?ll be prompted for the file namejust press ?Enter? for the default file nameThis command will create the .ssh subdirectory and generate the public and private encryption keys in the /home/SFTPUSER/.ssh directoryYou?ll have files id_dsa (the private key) and id_dsa.pub (the public key).

    3. Send the public key to your communications partnerThis can be done via e-mail or FTPYour communications partner will take your public key and place in its .ssh folder, and add your host name to its known_hosts file.

    4. If your partner has its own key (which is likely), you?ll use it for the transferGet it with this commandwhere your partner?s name is commpartner.com:

    ssh-keyscan -t commpartner.com >> ~/.ssh/known_hosts

    This adds your partner
    ?public key to your known_hosts file and enables secure communications between the systems
    and there is always Scott!


    Then goto index page of this site: code400.com -- under the OPERATIONS link look for sample titled : "Ftp to windows server process .csv tables"
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Receiving files through sftp.

      Can't you just do the following (or similar) to get all files that end with a given string?
      Code:
      get *txt
      Are we really talking about sftp? You meaning LSOUTPUT which is not related to sftp. (LSOUTPUT is FTP)

      Comment

      Working...
      X