April 17, 2018 - by Carol Cobine
This tutorial explains how to prepare Windows to install the triton
command line tools. In order to install triton
, you must first generate an SSH key pair and then upload the public key to Triton. To ensure a successful deployment on Windows, we perform these and other steps in a different order than you may be used to if you've used triton
on macOS.
Before you begin, ensure that you have a Triton Compute Service account with valid billing information.
You may also want to install a plain text editor. Technically, a text editor isn’t required to install Triton CLI, but it’s really handy way to take advantage of native Windows functionality. Unlike Microsoft Word and other word processors, plain text editors consist exclusively of character representation. There is no metadata encoded that may break your applications. It is important to understand the difference between these tools.
If you are comfortable with command line text editors such as nano or Vi, you may skip this step. However, Notepad++ is an easy-to-use, free text application. You can download and install Notepad++ from https://notepad-plus-plus.org.
Windows doesn't have a default SSH client. While there are many applications that offer SSH key generation, Git Bash is the most reliable way to generate SSH keys that are compatible with Triton. Git Bash, available with the Git installation package, provides a way to access and manage Triton containers at the command line. We recommend using the Git Bash client to generate SSH keys.
To install Git Bash:
When the installation completes, you may need to restart Windows.
Windows assumes that the Windows account you are using has administrative privileges. Given this, you create the SSH directory at the root of your profile, in your home directory C:\Users\ccobine
, and then generate the SSH key pair.
To run Git Bash as an Administrator, launch the application from the Windows command prompt:
C:\Program Files\Git\bin\bash.exe
and press Enter.ssh-keygen
.Note: Triton authenticates using the key fingerprint so adding a password is optional. When prompted for a password, you can choose to leave this field blank. If you enter a password, you will need to add it to ssh-agent
. You can learn more about this from our ssh-agent documentation.
Here is an example of the SSH generation commands and the resulting output:
$ mkdir .ssh
$ cd C:\Users\ccobine\.ssh
$ ssh-keygen.exe
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/ccobine/.ssh/id_rsa): /c/Users/ccobine/.ssh/
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/ccobine/.ssh/
Your public key has been saved in /c/Users/ccobine/.ssh/
The key fingerprint is:
SHA256:jieniOB720935n0nowo04n002HqEIOnTIOnevHzaI5nak ccobine@periwinkle
The key's randomart image is:
+---[RSA 2048]----+
|*= =+.. |
|O*=.B |
|+*o* + |
|o +o. . |
| ooo + S |
| .o.ooo* oo |
| .+o+*ooo . |
| .=+.. |
| Eo |
+----[SHA256]-----+
$ dir .ssh
id_rsa id_rsa.pub
As stated above, Triton authenticates using the key fingerprint. Once you create the key pair, you must upload the public key to Triton to associate it with your account.
To upload the public SSH key to your Triton account:
When Triton finishes the adding or uploading process, the public SSH key appears in the list of SSH keys. Now, you are ready to install Node.js.
To install Triton CLI or other CloudAPI tools, you must first install Node.js.
To install Node.js:
Once Node.js is installed, you can install triton
using Node Package Manager (npm
).
From the Git-Bash or Windows command line, you can issue the npm install
command with a global flag that installs the triton
, smartdc
, docker
, and other modules so that each is accessible to all users.
npm install -g triton
npm install –g smartdc
npm install –g docker
Environment variables are a way to store configurable values across your entire system. On Windows, you must configure environment variables to define the path information between Windows applications and to populate profile information referenced by Triton.
For Triton, you define environment variables in the bash profile, typically named .bashrc
. The bash profile is located in your home directory. If your home directory doesn't contain a bash profile, you can create a file named .bashrc
.
id_rsa.pub
.export TRITON_PROFILE="env"
export TRITON_URL="https://us-sw-1.api.joyent.com"
export TRITON_ACCOUNT=""
unset TRITON_USER
export TRITON_KEY_ID="$(ssh-keygen -l -f $HOME/.ssh/id_rsa.pub | awk '{print $2}')"
unset TRITON_TESTING
unset TRITON_PROFILE
After January 2018, environment variables are defined with TRITON_*
prefixes. In versions of triton
prior to January 2018, environment variables were defined with the SDC_*
prefixes. If you've installed smartdc
, you must also define SDC_*` environment variables in addition to TRITON_*
environment variables.
If you define both types of variables, your bash profile may look similar to:
export TRITON_PROFILE="env"
export TRITON_URL="https://us-sw-1.api.joyent.com"
export TRITON_ACCOUNT="ccobine"
unset TRITON_USER
export TRITON_KEY_ID="$(ssh-keygen -l -f $HOME/.ssh/id_rsa.pub | awk '{print $2}')"
unset TRITON_TESTING
export SDC_URL="https://us-sw-1.api.joyent.com"
export SDC_ACCOUNT="ccobine"
unset SDC_USER
export SDC_KEY_ID="$(ssh-keygen -l -f $HOME/.ssh/id_rsa.pub | awk '{print $2}')"
unset SDC_TESTING
unset TRITON_PROFILE
Defining environment variables in Windows ensures that the system properly sets the paths to the variables across applications for the current user account.
To configure system variables:
For triton
CLI, define variables for the User (current user) only. Creating global system variables can cause problems with ssh key validation.
TRITON_ACCOUNT
: the username of your Triton account or the name of your local SDC account.TRITON_URL
: The API endpoint for the datacenter to access. For this tutorial, use https://us-sw-1.api.joyent.com as the endpoint.TRITON_KEY_ID
: The fingerprint of your SSH public/private key pairTriton CLI stores access information in profiles. Profiles contain the data center CloudAPI endpoint, your account login, and SSH key fingerprint. Profiles make it easy to connect to different data centers, or connect to the same data center as different users.
The triton profile create
command prompts you to answer a series of questions to configure your profile. The following example shows the steps for the Triton user ccobine
:
$ triton profile create
A profile name. A short string to identify an endpoint to the `triton` CLI.
name: us-sw-1
The CloudAPI endpoint URL.
url: https://us-sw-1.api.joyent.com
Your account login name.
account: ccobine
The fingerprint of the SSH key you have registered for your account. You may enter a local path to a public or private key to have the fingerprint calculated for you.
keyId: ~/.ssh/.id_rsa
Fingerprint: 2e:c9:f9:89:ec:78:04:5d:ff:fd:74:88:f3:a5:18:a5
Saved profile "us-sw-1"
To test the initial profile configuration, run triton info
:
$ triton info
login: ccobine
name: Carol Cobine
email: ccobine@example.com
url: https://us-sw-1.api.joyent.com
totalDisk: 65.8 GiB
totalMemory: 2.0 GiB
instances: 2
running: 2
The triton info
output displays information about the profile we have just configured. Notice that you will see information about any instances you may have running. If you haven't created an instance, we'll show you how to do that after we set up a few more profiles.
Next, let's create a profile for each data center. For this tutorial, we run triton
commands to make a copy of a us-sw-1
profile for each of the data center urls. You can copy and paste the snippet below to create the new profiles:
triton datacenters | egrep -v NAME | while read -r i; do name=$(echo $i | awk {'print $1'}); url=$(echo $i | awk {'print $2'}); triton profile get -j env | sed -e "s/env/$name/" -e "s#http[^\"]*#$url#" | triton profile create -f - -y; done
Run triton profiles
again to check to see if the command worked. We should have a new profile for each data center listed in triton datacenters
:
$ triton profiles
NAME CURR ACCOUNT USER URL
env ccobine - https://us-sw-1.api.joyent.com
eu-ams-1 ccobine - https://eu-ams-1.api.joyent.com
us-east-1 ccobine - https://us-east-1.api.joyent.com
us-east-2 ccobine - https://us-east-2.api.joyent.com
us-east-3 ccobine - https://us-east-3.api.joyent.com
us-sw-1 * ccobine - https://us-sw-1.api.joyent.com
us-west-1 ccobine - https://us-west-1.api.joyent.com
Joyent's Triton CLI documentation contains more information on configuring profiles.
Now that you have triton
tools available and have basic profile and environment variables configured, you can begin provisioning instances. You can read more about creating instances in the Triton CLI documentation.
In this example, triton instance create
creates an Ubuntu instance named server-1:
$ triton instance create -w --name=server-1 ubuntu-14.04 g4-highcpu-1G
Creating instance server-1 (e9314cd2-e727-4622-ad5b-e6a6cac047d4, ubuntu-14.04@20160114.5, g4-highcpu-1G)
Created instance server-1 (e9314cd2-e727-4622-ad5b-e6a6cac047d4) in 22s
Let's try connecting to your new instance. You can also try connecting to an existing instance if you have previously created one using Triton CLI or on the portal.
In the Git Bash client, run the command triton ssh
, where
is the name of your instance.
triton ssh server-1
You are connected!
If the resulting output displays the message "key already exists for that server" error, you aren't celebrating a successful connection to your instance. The error message means that you've connected to the instance in the past and need to update the key for the instance.
To address this issue, you must obtain the IP address for the instance, try connecting directly to that IP address, and then run ssh-keygen
to update the key connected to the instance.
$ triton ip server-1
165.225.156.33
ssh root@165.225.156.33 -l root
ssh-keygen -R 165.225.156.33
ssh root@165.225.156.33 -l root
You should see the instance spinning up.
You may have noticed that we often reference our existing docs, such as the Triton CLI documentation, asking you to read them to explore more. Remember that setting up Triton in Windows simply requires that you perform the same steps detailed in our getting started documentation with just a few changes.
You can continue testing CloudAPI by running additional triton
commands. Finally, you can learn more about methods and resources in Joyent's reference documentation