[et_pb_section bb_built=”1″ _builder_version=”3.0.63″][et_pb_row _builder_version=”3.0.65″ background_position_1=”top_left” background_repeat_1=”no-repeat” background_position_2=”top_left” background_repeat_2=”no-repeat” module_id_2=”stickysidebar”][et_pb_column type=”4_4″][et_pb_text admin_label=”Blog Post” _builder_version=”3.17.2″]

Originally published: IT Jungle on 9/17/14
Updated author notes:There are new ways to set the default PASE shell on IBM i.

Original Article

It is interesting to observe where the IBM i side of IBM invest their resources. The operating system and database get a whole lot of investment but the native application layer seemingly not nearly as much. Why? Because I don’t believe they see a viable future for modern applications being written in timely fashion with the likes of RPG. If that were true then what future does the platform have? The PASE environment on IBM i is the remaining hope for the operating system to live in the realm of modernity. Why? Because that’s where modern things are being ported to run. First we had commercially supported Java, then PHP, and now Ruby – they all run in PASE. This article will give an introduction for how to work with PASE from what’s called an SSH session so you can begin to be made comfortable with this different approach in interacting with the IBM i server.

First let’s do some high level definitions of terms covered in this article:

PASE – An AIX integrated runtime environment on IBM i and is where Ruby runs. It does not include the AIX kernel and instead the IBM i kernel is called upon.

SSH – A cryptographic protocol used to securely communicate from your laptop to a shell session on IBM i.

Shell – A “shell” is a text-based interface that reads typed commands, runs them, and returns the output. Shell sessions are facilitated by IBM i jobs which you can view from WRKACTJOB. There are many different types of shells, each with its own flavors and utilities. Here we will be talking about what’s called the “bash” shell.

Bash – An implementation of a shell based on the original Bourne shell (sh). Bash stands for “Bourne-again shell”.

The IBM i ships with the Korn, Bourne, and C shells which can be started by typing CALL QP2TERM from a 5250 terminal. If you’ve ever used the terminal capabilities of Linux or Mac OSX you will soon realize using the aforementioned shells through a 5250 telnet session is cumbersome at best. Instead it is preferable to use an SSH client from your laptop to a bash shell on IBM i because of additional features – tab-completion, command history with up/down arrows, and the ability to use server-side editors like joe.

Starting SSH Daemon

Before you can login with SSH you need to make sure the SSH daemon service is running. Issue the following command to start it and if it is already running then a simple diagnostic message will be displayed back to you.


The SSH daemon job runs in subsystem QUSRWRK, as shown below.

The SSH daemon job running in subsystem QUSRWRK
The SSH daemon job running in subsystem QUSRWRK

You can now log in from your laptop with an SSH client. If your laptop is running Mac or Linux then you already have SSH client capabilities available through pre-installed applications (i.e. Terminal on Mac). If you are on Windows you will need to download a tool like Putty (free), as shown below. In the below screenshot the ‘user@’ is the IBM i profile and IP address. Clicking the Open button will start a session where you will be prompted for your IBM i profile’s password.

Logging into IBM i via SSH using PuTTY
Logging into IBM i via SSH using PuTTY

Below we see how to login from a Mac. After logging in, the pwd (print working directory) command is run so we can learn where we are at in the file system. The next command, echo $SHELL, is checking to see what shell we are using and in this case it shows bash. The bash shell utility doesn’t come with IBM i by default so the PowerRuby team has ported and included it with our installation (download your free copy here).

Logging into IBM i via ssh using Mac's Terminal
Logging into IBM i via ssh using Mac’s Terminal

SSH shell session is tied to an IBM i job, as shown below. Take option 5 and peruse through the various attributes of that job to see what it has for values, library list, etc. It is important to realize what is going on here because it is significant. We logged into a Linux-like environment yet it is in entire submission to the IBM i operating system kernel which inherently gives us all the security, workload balancing, and other features we’ve come to rely on.

Viewing the active SSH shell session
Viewing the active SSH shell session

Defaulting to Bash

Now that you are logged in using SSH it would be good to learn some personalization options as it relates to your environment. For example, it is possible to make the PowerRuby bash shell your system-wide default.

IFS file /QOpenSys/QIBM/UserData/SC1/OpenSSH/openssh-4.7p1/etc/sshd_config stores name-value-pairs of settings for SSH. You can edit the file with joe from an existing ssh session or EDTF from 5250 green screen, full commands shown below. Note that the joe editor is also included with the PowerRuby download.

joe /QOpenSys/QIBM/UserData/SC1/OpenSSH/openssh-4.7p1/etc/sshd_config


EDTF '/QOpenSys/QIBM/UserData/SC1/OpenSSH/openssh-4.7p1/etc/sshd_config'

Change the ibmpaseforishell line to look like the following:


Here is a sample screenshot of what the joe editor looks like when editing the sshd_config file. The whole screen is editable and there is even syntax coloring for certain file extensions (i.e. Ruby files ending in .rb).

Using the joe editor to modify sshd_config
Using the joe editor to modify sshd_config

After making changes to the sshd_config file you need to restart the SSH daemon with the following commands:


Sometimes it isn’t a reality to change system-wide settings and instead you may need to only change your profile to be defaulted to a different shell. This can be easily done by creating a .profile file inside your home directory and then adding the below shell script code to it.


# detect if we're in a PASE shell

if [ $? != 0 -a "$SHELL" != "/QOpenSys/usr/bin/bash" ]
 exec /QOpenSys/usr/bin/bash

The .profile file will be processed when a shell session is started and place you into a bash shell. The reference to /QOpenSys/usr/bin/bash is actually a symbolic link that points at /PowerRuby/oss/bin/bash.

If you don’t want to change sshd_config or write a script for .profile there is still the manual way of entering into bash by typing /PowerRuby/oss/bin/bash in your current SSH session. Note that by doing this you are actually creating a second IBM i job, one for each shell session. To exit the second shell session you can type “exit” and then you will be placed into the initial shell session. Typing “exit” again will log you out of the IBM i shell session.

Increasing Shell Session Timeout

It can be frustrating to have your 5250 telnet sessions timeout, and the same is true for SSH sessions. You can address this by modifying the same sshd_config file:


Search for ClientAliveInterval, remove the pound comment operator (‘#’) and change the setting equal to the number of seconds you’d like your shell to be open until it automatically closes due to no usage. For example, set your system to the following to have a timeout of 30 minutes:

ClientAliveInterval 1800

After making changes to the sshd_config file you need to restart the SSH server daemon with the following commands:


That concludes this tutorial on using PASE, SSH, and bash on your IBM i. For a variety of more info on PASE related things you can check out the YiPs (Young i Professionals) wiki. The YiPs wiki is actually very active and new content is frequently being added and changed.

[/et_pb_text][/et_pb_column][/et_pb_row][et_pb_row _builder_version=”3.0.65″ background_position_1=”top_left” background_repeat_1=”no-repeat” module_id_1=”stickystop”][et_pb_column type=”4_4″][et_pb_text admin_label=”Contact Form Title” _builder_version=”3.17.2″ background_layout=”dark” text_font=”Raleway|on|||” text_text_color=”#f45d01″ text_font_size=”26″ text_letter_spacing=”2px”]

Need help with PASE or Bash on IBM i? Contact us.