Remote Editing with VS Code on IBM i
Before you start!
This document assumes that you have already installed Profound.js onto your IBM i, and that you have installed VS Code onto your local workstation. You can find more detailed installation instructions for Profound.js here, and you can find more detailed installation instructions for VS Code here. This tutorial was written for what was at the time the most recent version of SSH FS, some steps may look different if you are using a newer version of SSH FS then when this tutorial was written.
Disclaimer
VS Code: The What and Why
VS Code is a cross-platform, multi-language code editor. With inline IntelliSense, debugging support for multiple languages, inline git support and an extensible API for plugins, it's the editor that has no boundaries.
Because VS Code is great for it's inline debugging support, it is only natural to also want to edit the remote code stored on the IBM i with the same text editor.
To download and read more about VS Code, check out the following links:
- https://code.visualstudio.com/
- https://code.visualstudio.com/docs/editor/whyvscode
- https://code.visualstudio.com/docs/nodejs/nodejs-tutorial
- https://code.visualstudio.com/docs/nodejs/nodejs-debugging
VS Code: The Walkthrough
VS Code Remote Editing Setup
After installing VS Code, the first step to enable editing of remote IFS files would be to install the SSH FS extension from the Extensions tab.
- From the Extensions tab in VS Code, search for the SSH FS extension, and click the green button labeled 'Install' to add the SSH FS extension to your copy of VS Code.
- The next step is to create SSH FS configurations in the Explorer tab, so that you can define your connection to the IBM i IFS. Right-click under the SSH File Systems section and select 'Create a SSH FS configuration'.
- You may first need to enable the SSH File Systems section of the Explorer tab by right-clicking on 'Explorer' and toggling the appropriate option.
- You may first need to enable the SSH File Systems section of the Explorer tab by right-clicking on 'Explorer' and toggling the appropriate option.
- At the top of the screen, you will be prompted to provide a name for the new connection. This is the short name that will allow you to differentiate between the connections at a glance, but you can provide a more detailed name later. An example would be the name of the IBM i system, or the name of the Profound.js instance.
- After providing a name, the SSH FS extension will create a configuration file for this connection. Here, you will enter your connection details to SSH into your IFS. After entering the correct details, save the configuration file and the connection will be created and saved under the SSH File Systems section. Below is a short description of the configuration options, as well as an example setup for a connection.
- "label": This is where you can specify a more detailed name for the connection that can include white space. For example, if I were setting up a connection to the root of the IFS on a system named Power8, I can provide a label of "Power8 root".
- "root": This is the root directory of the SSH connection. You will not be able to access files outside of this file path on the IFS with this connection. For example, if I wanted access to the IFS's root directory I would specify "/", however, if I wanted to only access an instance of Profound.js I would provide the file path to that Profound.js installation folder "/profoundjs".
- "host": This is the host name of the IFS. Meaning, this is the IP address or hostname you would type into the web browser to access your IBM i. Examples: "power8", "10.0.0.1"
- "port": This is the port used for SSH FTP. The default for most systems is 22.
- "username": This is the username of the account you will use to log into SSH. This can be the same as your IBM i profile. Example: "QPGMR"
- "password": Here you can either pass true to have VS Code prompt you for your password every time you try to open the connection, or you can hard code your password into the configuration file to have VS Code automatically log in for you. In the above example, this would only work if the KLAW user profile had their password set to 'password'.
- If you set the password field to true, the password prompt would appear at the top of the VS Code window like this:
- If you set the password field to true, the password prompt would appear at the top of the VS Code window like this:
- After creating the configuration and saving the file, you will need to open the connection. You can do this by right-clicking on the configuration in the SSH File Systems section, and selecting the "Connect as Workspace folder" option. If you set the password field to true, you would be prompted to enter your password at this point.
- After the connection is established, you will see the file tree in your workspace which starts at the root directory you specified in the configuration. You can now simply open files from the IFS by clicking on the files in the file tree. When you save the files in VS Code, the changes will automatically be saved and uploaded to the IFS.
Some documentation pages have recently moved to a new section: Profound AppDev. If you are having trouble finding specific pages, try the documentation search capability or reach out to our Support team!