Edit IFS Files Using Visual Studio Code for IBM i
Visual Studio Code (VS Code) is a lightweight source code editor that runs on multiple desktops, including Windows, Linux, and MacOS. It provides built-in support for PHP, Node.js, Python, and many other languages and runtimes.
Halcyon Tech’s Code for IBM i extension adds the ability to edit IBM i Integrated File System (IFS) files inside VS Code. It’s easy to get set up to access and edit IFS-based code using this popular editing tool.
In just seven quick steps, you can install VS Code and its Code for IBM i extension and begin working with IFS files stored on your IBM i.
Step 1: Enable SSH on your IBM i
SSH must first be enabled on your target IBM i servers to allow VS Code to access IFS files. If your IBM i isn’t already set up for SSH access, follow these instructions to configure and enable SSH on an IBM i server.
Step 2: Configure and test SSH-to-IBM i connectivity for client machines
Using the same SSH configuration instructions referenced in step one, configure and test that your Code for IBM i client systems will be able to authenticate to your target IBM i using SSH. Confirm that their SSH-to-IBM i connectivity works before trying to connect using VS Code for IBM i.
Authentication to your SSH-enabled IBM i can be performed either by using an IBM i user profile and password or by using a public-private pair of SSH keys.
Also check the user’s IBM i authorities for any IFS folders they’ll want to access through the Code for IBM i extension. Our testing found that at the very minimum, Code for IBM i extension users must have *READ, *WRITE, and *EXECUTE access or ownership rights to their home IFS directory (usually /home/user_name) before they can connect to a target IBM i system using SSH.
Step 3: Install VS Code and its IBM i extensions
Next, if you haven’t already done so, install Visual Studio Code on your client machines.
Once installed, access the VS Code extension list from the “squares” icon in its left-hand panel, marked as “1” in the screen shot below. Then use the extensions search bar, marked as “2” below, to search for Code for IBM i and install it.
Next, search for and install the IBM i Development Pack extension, which looks like this:
Once installed, you will see the VS Code for IBM i icon here. Click the icon.
Step 4: Setting up a VS Code-to-IBM i connection
The IBM i icon shows you the current list of IBM i servers you can connect to (shown below). You can set up one or many IBM i connections using this screen.
The IBM i connection list (1) will be blank the first time you access it. You can create a new Code-to-IBM i connection by either clicking on the plus + sign (2) at the top of the IBM i screen or by clicking on the Connect to an IBM i button (3, although depending on your configuration, the Connect to an IBM i button may not be available inside the IBM i screen).
Step 5: Setting up your IBM i settings
Your Code for IBM i extension will prompt you for the login settings to connect to your target IBM i, using an IBM i Login screen similar to what’s shown here.
Fill in the values that are appropriate for an IBM i connection.
- Enter a name for your new connection in the Connection Name input box.
- Enter the DNS host name or the IP address of the IBM i server you’ll be connecting to in the Host or IP Address input box.
- Enter the IBM i user profile name you will connect with in the Username box.
- Type the port number for your IBM i SSH connection in the Port (SSH) box. SSH connections typically run on Port 22. Check with your IBM i administration to find the correct port number for your connection.
- You can connect either by using the IBM i user profile password or by using the client’s private SSH key you created in Step 2. Note you can’t use both connection parameters for an IBM i connection. If using the user profile password, fill in the correct password in the Password input box. If using a SSH private key, upload the private SSH key file using the Private Key box.
Click the Save & Exit button at the bottom of your IBM i Login entry to save your connection values.
As mentioned in Step 4, you can connect to your target server by either clicking on the + (plus) sign next to the IBM i SERVERS text at the top of the IBM i screen or by clicking on the Connect to an IBM i button (if available.) Select the connection entry you want to use and the extension should connect you to your target IBM i.
After a successful connection, you’ll see a message in the bottom lower right of your IBM i connection screen, similar to this message.
Step 6: Viewing and working with IFS files
Once connected, you’ll have the option to modify your user library list (User Library List), browse IBM i native objects (Object Browser), or to work with, edit, or add IFS shortcuts to your IFS folders (IFS Browser). This will be done through the IBM i screen, similar to the screen shown below.
The first time you open the IFS Browser with a new connection, you will be able to see only the folders and files under the user’s home directory. To view additional directories in the IFS Browser, click on the ‘+’ (plus) sign in the IFS Browser section. You can enter individual folders to add to an IFS Browser setup, or you can enter the ‘/’ (root) folder as an IFS Browser shortcut. Your user will see all the IFS folders and sub-folders that were entered in their IFS Browser setup.
Note: While users can see any number of IFS folder shortcuts, they will be able to open and access only the IFS folders and files to which they are authorized.
Step 7: Add or change IBM i server connections
The Code for IBM i extension allows you to add connections for multiple IBM i servers or to change an existing connection.
If you want to edit your connection settings, right click on the connection and choose connection settings.
If you want to connect to an additional IBM i system, select File > New Window from the VS Code menu and then return to the IBM i option in the left-hand panel to add a connection.
Using VS Code as a development tool of choice for IFS files
As you can see, it’s extremely easy to edit IBM i IFS-based source code using Code for IBM i extension inside a VS Code setup. This enables VS Code users to use their favorite tool-of-choice when developing and editing PHP, Node.js, Python, and other modern application code for IBM i deployment.
For additional information on using Code for IBM i, view our VS Code for i Resource Guide.
Leave a Reply
Want to join the discussion?Feel free to contribute!