Skip to main content

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"

NameDescriptionAdditional Notes
hostSSH Server HostAppears when hovering over the status bar.
usernameSSH Server UsernameThe username to establish the SSH connection to the server.
portSSH Server PortThe SSH port of the SSH server. The default value is 22.
saspathPath to SAS Executable on the serverMust 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

  1. Enable OpenSSH for Windows using these instructions.

  2. 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.

  3. Ensure that the ssh-agent service is running and set the Startup type to Automatic using these instructions

  4. 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"
  1. 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]
  2. 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

  1. Add the private key to ssh-agent: ssh-add /path/to/private/key/with/passphrase

  2. 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.

  1. 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

  1. Start ssh-agent in the background:
eval "$(ssh-agent -s)"
  1. Ensure that SSH_AUTH_SOCK has a value
echo $SSH_AUTH_SOCK
  1. 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
  1. Add the private key to ssh-agent: ssh-add /path/to/private/key/with/passphrase

  2. 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
}
  1. Add the public part of the keypair to the SAS server. Add the contents of the key file to the ~/.ssh/authorized_keys file.