ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to set remote CCSID for sftp

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

  • How to set remote CCSID for sftp

    I have a problem after system upgrade to 7.5.
    New *STMF which are sent by clients obtain 819 CCSID.
    I changed default CCSID for dir to 912. Nothing change, still new file obtain 819 CCSID.

    Do you have any idea how to set default CCSID to 912?

  • #2
    More tests
    1. QSH
    echo "kuku">/test.txt
    CCSID for test.txt is taken from USRPRF

    2. QP2TERM
    CCSID is fixed to 819.
    It seems the same source CCSID as for SFTP server

    Does anybody know how iSeries "calc" CCSID for SFTP server?

    Comment


    • #3
      I don't understand this thread. You say you changed the default CCSID for the dir to 912. How on earth do you change the default CCSID for a dir? I've never heard of that in my life.

      Just to be clear... SFTP is a Unix program that runs in PASE. It has no concept of CCSIDs. CCSID is not a concept that is typically used in the Unix world... But you told us that this worked before you upgraded to 7.5 -- which makes no sense at all... doesn't matter what version of IBM i you are running, first of all, bcause the program run in PASE, and second of all because Unix has no concept of CCSIDs... I'm assuming that in reality, this never worked.

      Your QSH/QP2TERM tests make no sense at all unless you are using them to precreate the file or something? But you say the files are sent by clients... to me that assumes you are using SFTP (SSH) as a server, since the the files are sent from elsewhere by clients. That being the case, I can't see how shells that are not even part of the process can possibly matter.

      My suggestion is to set the CCSID after the file is transferred. You can do that from QShell or PASE with the 'setccsid' command. Or from CL with the CHGATR command.

      Comment


      • #4
        Is this what you're referring to? Is it coming up as 1208?

        Comment


        • #5

          Applies to CCSID change for DIR.

          Code:
          CHGATR OBJ("dir_name") ATR(*CCSID) VALUE(912)
          I haven't heard of it either, but it can be done as above.


          At first I thought the problem was with the SFTP server. But the real problem is how the operating system assigns the CCSID to *STMF objects on IFS. What is the default CCSID.
          I didn't find a clear explanation in the IBM documentation.
          I assume that the CCSID that is set to the profile with which we connect using SFTP is selected. This may have worked in V7R3 but not in V7R5.

          This is the essence of the problem. Does anyone know how iSeries OS 7R5 assigns the CCSID to new files on IFS for *STMF?​

          Comment


          • #6
            About IBM doc:

            When a PASE application is started using the QP2TERM and QSH shell environments or QP2SHELL and QP2SHELL2 APIs, a matching PASE CCSID and PASE locale are selected based on the current job's LANGID and CNTRYID. For most LANGID/CNTRYID pairs, in IBM® i 7.3 and prior releases, a single byte encoding such as ISO-8859-1 (819) was used and a matching single byte PASE locale was selected. For any LANGID/CNTRYID pair which did not have a corresponding PASE locale, the POSIX locale was used with CCSID 819.

            In IBM i 7.4, the default is now UTF-8 (1208) for all locales. If a valid PASE locale is not found for the current LANGID/CNTRYID, the POSIX locale is still used, but the CCSID is set to 1208.

            Setting the environment variable PASE_DEFAULT_UTF8 to "N" in the current job will allow the prior behavior to be used. Any active QP2TERM or QSH sessions will have to be ended and restarted to take effect.
            So it means that: Setting the environment variable PASE_DEFAULT_UTF8 to "N" should restore previous behaviour.

            I check

            Comment


            • #7
              I set PHASE_DEFAULT_UTF8='N' and restarted sshd.
              *STFM file are still saved by SSHD server with CCSID=819​

              I check with PHASE_DEFAULT_UTF8='"N"'

              Comment


              • #8
                I made mistake it should be PASE instead PHASE

                So,
                After settting PASE_DEFAULT_UFT8='N'

                I see for job environmant variables
                PASE_DEFAULT_UTF8='N'
                QIBM_PASE_CCSID=912 (great !!! because was 1208)

                But files on IFS are save with ... 819 .


                Comment


                • #9
                  About:
                  SFTP is a Unix program that runs in PASE. It has no concept of CCSIDs. CCSID is not a concept that is typically used in the Unix world... But you told us that this worked before you upgraded to 7.5 -- which makes no sense at all... doesn't matter what version of IBM i you are running, first of all, bcause the program run in PASE, and second of all because Unix has no concept of CCSIDs... I'm assuming that in reality, this never worked.
                  As I understood, SSHD saves RAW data in a specific location.
                  The recording is done via the PASE shell.
                  So it is the PASE shell or the tool that PASE uses that gives the CCSID to the data it writes (*STMF).

                  Tests show that the QIBM_PASE_CCSID environment variable does NOT work for version V7R5. Because even the variable has the value 912, the result has CCSID = 819.

                  The question is where does the PASE shell come up with 819?

                  To duplicate the problem, you don't need SSHD, you can set QIBM_PASE_CCSID=912 and echo "bum">test.txt
                  and test.txt will have CCSID 819.

                  Any idea why 819?

                  Comment


                  • #10
                    I checked the V7R3 version and the ​QIBM_PASE_CCSID environment variable has no effect on the produced CCSID of the file, so what does it have?

                    Comment


                    • #11
                      Interesting thing. When I change the environment variable using WRKENVVAR, I always see the value of this variable from the first run of QP2TERM, despite *ACTGRP= *NEW.
                      For QSH, the update occurs every time it is started​

                      Comment


                      • #12
                        QSH responds correctly to changes QIBM_CCSID environmant variable

                        Comment


                        • #13
                          Err.. is the ultimate goal to make the SSHD assign the appropriate CCSID, or to make file redirection in an interactive shell create a file with the appropriate CCSID? I can't understand why you keep trying to get file redirection to do it?

                          Comment


                          • #14
                            What I see in the docs you copy/pasted above is this:
                            a matching PASE CCSID and PASE locale are selected based on the current job's LANGID and CNTRYID.
                            I don't see anything that claims you can change QIBM_PASE_CCSID?? Why did you decide to do that?

                            As a test, I did this:
                            • ADDENVVAR ENVVAR(PASE_DEFAULT_UTF8) VALUE(N) REPLACE(*YES)
                            • CHGJOB LANGID(CSY) CNTRYID(CZ)
                            • CALL QP2TERM
                            • echo "x" > myfile.txt


                            The result was that myfile.txt was in CCSID 912. (this also means that my whole session used Czech settings, which is fine if that's the way you want your session to work. But since I'm in the USA, that's a little weird.)

                            But it seemed to work exactly as it states in the docs you quoted. I'm still not sure what this has to do with SSHD.

                            Comment


                            • #15
                              Assuming the PASE_DEFAULT_UTF8 variable is necessary for your soluition, you won't be able to just set it in your interactive session. The SSHD doesn't run in that session, it runs in a server job in the background... a completely different job with completely different environment variables...

                              You could try adding something like the following to the sshd_config and restarting the SSHD.
                              Code:
                              ibmpaseforienv PASE_DEFAULT_UTF8=N
                              And CHGJOB isn't going to help with SSHD, you'd need to change the actual system values to be the correct ones to produce CCSID 912 (such as the czech settings I tested above.) Personally, I'd be very worried about doing that since it'll affect all users. (Unless you are a Czech shop, in which case that's probably what you want.)

                              Once you've made these changes, you'd restart the SSHD for the changes to take effect.

                              Having said that, it seems far easier to use setccsid or CHGATR to change the CCSID of the file after the transfer -- I really don't understand why you want to change all of this. Also, I think UTF-8 is generally a better choice for a detault.

                              Comment

                              Working...
                              X