SAS 9.4 (remote - SSH) Connection Profile
For a secure connection to SAS 9.4 (remote - SSH) server, a public / private SSH key pair is required. The socket defined in the environment variable SSH_AUTH_SOCK
is used to communicate with ssh-agent to authenticate the SSH session. The private key must be registered with the ssh-agent. The steps for configuring SSH follow.
Profile Anatomy
A SAS 9.4 (remote – SSH) connection profile includes the following parameters:
"connectionType": "ssh"
Name | Description | Additional Notes |
---|---|---|
host | SSH Server Host | Appears when hovering over the status bar. |
username | SSH Server Username | The username to establish the SSH connection to the server. |
port | SSH Server Port | The SSH port of the SSH server. The default value is 22. |
saspath | Path to SAS Executable on the server | Must be a fully qualified path on the SSH server to a SAS executable file. |
Required setup for connection to SAS 9.4 (remote - SSH)
In order to configure the connection between VS Code and SAS 9, you must configure OpenSSH. Follow the steps below to complete the setup.
Windows
-
Enable OpenSSH for Windows using these instructions.
-
Create an environment variable named SSH_AUTH_SOCK with value
//./pipe/openssh-ssh-agent
(Windows uses a named pipe for the auth sock).Note: An attempt to create the varible using Powershell command line did not register; suggest using these GUI instructions.
-
Ensure that the ssh-agent service is running and set the Startup type to Automatic using these instructions
-
Generate ed25519 keys with the following command (email address is not binding; you can use any email address):
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "youremail@company.com"
-
You are prompted to enter additional information. If you did not enter a path, a default path is provided for you. You can also specify a passphrase. If you do not specify a passphrase, your key is not password-protected. Press Enter to accept the default value for each prompt.
- Enter a file in which to save the key (/c/Users/you/.ssh/id_ed25519):[Press enter]
- Enter passphrase (empty for no passphrase): [Type a passphrase]
- Enter same passphrase again: [Type passphrase again]
-
Define an entry in ~/.ssh/config using the following format:
Host host.machine.name
AddKeysToAgent yes
IdentityFile /path/to/private/key/with/passphrase
Note: if ~/.ssh/config does not exist, run the following Powershell command to create it: Out-File -FilePath config
-
Add the private key to ssh-agent: ssh-add /path/to/private/key/with/passphrase
-
In VS Code, define a connection profile (see detailed instructions in the Add New Connection Profile section). The connection for the remote server is stored in the settings.json file.
"ssh_test": {
"connectionType": "ssh",
"host": "host.machine.name",
"saspath": "/path/to/sas/executable",
"username": "username",
"port": 22
}
Note: the default path to the SAS executable (saspath) is /opt/sasinside/SASHome/SASFoundation/9.4/bin/sas_u8. Check with your SAS administrator for the exact path.
- Add the public part of the keypair to the SAS server. Add the contents of the key file to the ~/.ssh/authorized_keys file.
Mac
- Start ssh-agent in the background:
eval "$(ssh-agent -s)"
- Ensure that SSH_AUTH_SOCK has a value
echo $SSH_AUTH_SOCK
- Define an entry in $HOME/.ssh/config of the form:
Host host.machine.name
AddKeysToAgent yes
UseKeychain yes
IdentityFile /path/to/private/key/with/passphrase
-
Add the private key to ssh-agent: ssh-add /path/to/private/key/with/passphrase
-
Define a connection profile in settings.json for a remote server (see detailed instructions in the Add New Connection Profile section):
"ssh_test": {
"connectionType": "ssh",
"host": "host.machine.name",
"saspath": "/path/to/sas/executable",
"username": "username",
"port": 22
}
- Add the public part of the keypair to the SAS server. Add the contents of the key file to the ~/.ssh/authorized_keys file.