Merge branch 'master' into 1971-show-image-thumbnails
[arvados.git] / doc / user / getting_started / ssh-access.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: Accessing an Arvados VM over ssh
5 ...
6
7 Arvados requires a public ssh key in order to securely log in to an Arvados VM instance, or to access an Arvados @git@ repository.
8
9 This document is divided up into three sections.
10
11 # "Getting your ssh key":#gettingkey
12 # "Adding your key to Arvados Workbench":#workbench
13 # "Using ssh to log into an Arvados VM instance":#login
14
15 h1(#gettingkey). Getting your ssh key
16
17 # "Using Unix ssh":#unix (Linux, OS X, Cygwin)
18 # "Using PuTTY":#windows (Windows)
19
20 h2(#unix). Unix: Using ssh-keygen
21
22 Start by opening a terminal window.  Check if you have an existing public key:
23
24 notextile. <pre><code>$ <span class="userinput">ls ~/.ssh/id_rsa.pub</span></code></pre>
25
26 If the file @id_rsa.pub@ exists, then you may use your existing key.  Copy the contents of @~/.ssh/id_rsa.pub@ onto the clipboard (this is your public key).  You can skip this step and proceed by "adding your key to the Arvados Workbench.":#workbench
27
28 If there is no file @~/.ssh/id_rsa.pub@, you must generate a new key.  Use @ssh-keygen@ to do this:
29
30 <notextile>
31 <pre><code>$ <span class="userinput">ssh-keygen -t rsa -C "you@example.com"</span>
32 Generating public/private rsa key pair.
33 Enter file in which to save the key (/home/example/.ssh/id_rsa):
34 Enter passphrase (empty for no passphrase):
35 Enter same passphrase again:
36 </code></pre>
37 </notextile>
38
39 * @-t@ specifies the key type (must be "rsa")
40 * @-C@ specifies a comment (to remember which account the key is associated with)
41
42 We strongly recommend that you protect your key with a passphrase.  This means that when the key is used, you will be required to enter the passphrase.  However, unlike logging into remote system using a password, the passphrase is never sent over the network, it is only used to decrypt your private key.
43
44 Display the contents of @~/.ssh/id_rsa.pub@ (this is your public key) using @cat@ and then copy it onto the clipboard:
45
46 <notextile>
47 <pre><code>$ <span class="userinput">cat ~/.ssh/id_rsa.pub</span>
48 ssh-rsa AAAAB3NzaC1ycEDoNotUseExampleKeyDoNotUseExampleKeyDoNotUseExampleKeyDoNotUse9lmzkpBq983bQradKGT3LuKda9QOGe8MatI6wzSrJLSGhHm3hk6D8OWWUG4SneuCtKIk2bH0pgBj1G29+uzDIez90WzfCTZKbz4RcVQmPkowSSUAQDwb0ffwvRDhCgcJ1loT1wQAJzqJmljQ7xEYaCOIMqnfYE0lX7B3MSvCV6Ie2rWL33YecLp48LVtqiCOZU4XRyO8RSDFRFLVW+mjkLirwtDHZCRtORScaIEN0jw51p+T+9X5iA9QH/Mn+xlgk7fCgH+JtpBj808N/Qds2Gpff+Kb6ulUrVVfMK6L you@example.com
49 </code></pre>
50 </notextile>
51
52 Now you can set up @ssh-agent@ (next) or proceed with "adding your key to the Arvados Workbench.":#workbench
53
54 h3. Setting up ssh-agent (recommended)
55
56 If you find you are entering your passphrase frequently, you can use @ssh-agent@ to manage your credentials.  Use @ssh-add -l@ to test if you already have ssh-agent running:
57
58 notextile. <pre><code>$ <span class="userinput">ssh-add -l</span></code></pre>
59
60 If you get the error "Could not open a connection to your authentication agent" you will need to run @ssh-agent@ with the following command:
61
62 notextile. <pre><code>$ <span class="userinput">eval $(ssh-agent -s)</span></code></pre>
63
64 @ssh-agent -s@ prints out values for environment variables SSH_AUTH_SOCK and SSH_AGENT_PID and then runs in the background.  Using "eval" on the output as shown here causes those variables to be set in the current shell environment so that subsequent calls to @ssh@ can discover how to access the @ssh-agent@ daemon.
65
66 After running @ssh-agent@, or if @ssh-add -l@ prints "The agent has no identities", then you will need to add your key using the following command.  The passphrase to decrypt the key is the same used to protect the key when it was created with @ssh-keygen@:
67
68 <notextile>
69 <pre><code>$ <span class="userinput">ssh-add</span>
70 Enter passphrase for /home/example/.ssh/id_rsa:
71 Identity added: /home/example/.ssh/id_rsa (/home/example/.ssh/id_rsa)
72 </code></pre>
73 </notextile>
74
75 When everything is set up, @ssh-add -l@ should yield output that looks something like this:
76
77 <notextile>
78 <pre><code>$ <span class="userinput">ssh-add -l</span>
79 2048 eb:fa:15:f2:44:26:95:58:37:37:f4:aa:ff:ee:c2:85 you@example.com (RSA)
80 </code></pre>
81 </notextile>
82
83 You may now proceed to "adding your key to the Arvados Workbench.":#workbench
84
85 h2(#windows). Windows: Using PuTTY
86
87 (Note: if you are using the @ssh@ client that comes with "Cygwin":http://cygwin.com you should follow the "Unix":#unix instructions).
88
89 "PuTTY":http://www.chiark.greenend.org.uk/~sgtatham/putty/ is a free (MIT-licensed) Win32 Telnet and SSH client. PuTTY includes all the tools a Windows user needs to create private keys and make ssh connections to your virtual machines in the Arvados Cloud.
90
91 You can "download PuTTY from its Web site":http://www.chiark.greenend.org.uk/~sgtatham/putty/.  Note that you should download the installer or .zip file with all of the PuTTY tools (PuTTYtel is not required).
92
93 h3. Step 1 - Adding PuTTY to the PATH
94
95 # After downloading PuTTY and installing it, you should have a PuTTY folder in @C:\Program Files\@ or @C:\Program Files (x86)\@ (if you are using a 64 bit operating system).  If you downloaded a zip file, extract it to the location you wish to install the PuTTY applications.
96 # Open the Control Panel.
97 # Select _Advanced System Settings_, and choose _Environment Variables_.
98 # Under system variables, find and edit @PATH@.
99 # If you installed PuTTY in @C:\Program Files\PuTTY\@, add the following to the end of PATH (make sure to include semicolon and quotation marks):
100 <code>;\"C:\Program Files\PuTTY\"</code>
101 If you installed PuTTY in @C:\Program Files (x86)\PuTTY\@, add the following to the end of PATH (make sure to include semicolon and quotation marks):
102 <code>;\"C:\Program Files (x86)\PuTTY\"</code>
103 # Click through the OKs to close all the dialogs you’ve opened.
104
105 h3. Step 2 - Creating a Public Key
106
107 # Start PuTTYgen from the Start Menu or the folder where it was installed.
108 # At the bottom of the window, make sure the ‘Number of bits in a generated key’ field is set to 4096.
109 # Click Generate and follow the instructions to generate a key.
110 # Click to save the Public Key.
111 # Click to save the Private Key (we recommend using a strong passphrase).
112 # Select the text of the Public Key and copy it to the clipboard.
113
114 h3. Step 3 - Set up Pageant
115
116 Pageant is a PuTTY utility that manages your private keys so is not necessary to enter your private key passphrase every time you make a new ssh connection.
117
118 # Start Pageant from the Start Menu or the folder where it was installed.
119 # Pageant will now be running in the system tray. Click the Pageant icon to configure.
120 # Choose _Add Key_ and add the private key which you created in the previous step.
121
122 You are now ready to proceed to "adding your key to the Arvados Workbench.":#workbench
123
124 h1(#workbench). Adding your key to Arvados Workbench
125
126 h3. From the Workbench dashboard
127
128 If you have no ssh keys registered, there should be a notification asking you to provide your ssh public key.  On the Workbench dashboard, look for the envelope icon <span class="glyphicon glyphicon-envelope"></span> <span class="badge badge-alert">1</span> in upper right corner (the number indicates there are new notifications).  Click on this icon and a dropdown menu should appear with a message asking you to add your public key.  Paste your public key into the text area provided and click on the check button to submit the key.  You are now ready to "log into an Arvados VM":#login.
129
130 h3. Alternate way to add ssh keys
131
132 If you want to add additional ssh keys, click on the user icon <span class="glyphicon glyphicon-user"></span> in the upper right corner to access the user settings menu, and click on the menu item *Manage ssh keys* to go to the Authorized keys page.
133
134 On the *Authorized keys* page, the click on the button <span class="btn btn-primary disabled">Add a new authorized key</span> in the upper right corner.
135
136 The page will reload with a new row of information.  Under the *public_key* column heading, click on the cell +none+.  This will open an editing popup as shown in this screenshot:
137
138 !{{ site.baseurl }}/images/ssh-adding-public-key.png!
139
140 Paste the public key that you copied to the cliboard in the previous section into the popup text box, then click on the check mark to save it.  This should refresh the page with the public key that you just added now listed under the *public_key* column.  You are now ready to "log into an Arvados VM":#login.
141
142 h1(#login). Using ssh to log into an Arvados VM
143
144 To see a list of virtual machines that you have access to and determine the name and login information, click on Compute %(rarr)&rarr;% Virtual machines.  Once on the *Virtual machines* page, The *hostname* columns lists the name of each available VM.  The *logins* column will have a value in the form of @["you"]@.  Your login name is the text inside the quotes.  In this guide the hostname will be _shell_ and the login will be _you_.  Replace these with your hostname and login name as appropriate.
145
146 This section consists of two sets of instructions, depending on whether you will be logging in using a "Unix":#unixvm (Linux, OS X, Cygwin) or "Windows":#windowsvm client.
147
148 h2(#unixvm). Logging in using command line ssh (Unix)
149
150 h3. Connecting to the virtual machine
151
152 Use the following command to connect to the _shell_ VM instance as _you_.  Replace *<code>you@shell</code>* at the end of the following command with your *login* and *hostname* from Workbench:
153
154 notextile. <pre><code>$ <span class="userinput">ssh -o "ProxyCommand ssh -a -x -p2222 turnout@switchyard.{{ site.arvados_api_host }} <b>shell</b>" -A -x <b>you@shell</b></span></code></pre>
155
156 This command does several things at once. You usually cannot log in directly to virtual machines over the public Internet.  Instead, you log into a "switchyard" server and then tell the switchyard which virtual machine you want to connect to.
157
158 * @-o "ProxyCommand ..."@ configures ssh to run the specified command to create a proxy and route your connection through it.
159 * @-a@ tells ssh not to forward your ssh-agent credentials to the switchyard.
160 * @-x@ tells ssh not to forward your X session to the switchyard.
161 * @-p2222@ specifies that the switchyard is running on non-standard port 2222.
162 * <code>turnout@switchyard.{{ site.arvados_api_host }}</code> specifies the user (@turnout@) and hostname (@switchyard.{{ site.arvados_api_host }}@) of the switchyard server that will proxy our connection to the VM.
163 * *@shell@* is the name of the VM that we want to connect to.  This is sent to the switchyard server as if it were an ssh command, and the switchyard server connects to the VM on our behalf.
164 * After the ProxyCommand section, we repeat @-x@ to disable X session forwarding to the virtual machine.
165 * @-A@ specifies that we want to forward access to @ssh-agent@ to the VM.
166 * Finally, *<code>you@shell</code>* specifies your login name and repeats the hostname of the VM.  The username can be found in the *logins* column in the VMs Workbench page, discussed in the previous section.
167
168 You should now be able to log into the Arvados VM and "check your environment.":check-environment.html
169
170 h3. Configuration (recommended)
171
172 The command line above is cumbersome, but you can configure ssh to remember many of these settings.  Add this text to the file @.ssh/config@ in your home directory (create a new file if @.ssh/config@ doesn't exist):
173
174 <notextile>
175 <pre><code class="userinput">Host *.arvados
176   ProxyCommand ssh -a -x -p2222 turnout@switchyard.{{ site.arvados_api_host }} $SSH_PROXY_FLAGS %h
177   User <b>you</b>
178   ForwardAgent yes
179   ForwardX11 no
180 </code></pre>
181 </notextile>
182
183 This will recognize any host ending in ".arvados" and automatically apply the proxy, user and forwarding settings from the configuration file, allowing you to log in with a much simpler command:
184
185 notextile. <pre><code>$ <span class="userinput">ssh <b>shell</b>.arvados</span></code></pre>
186
187 h2(#windowsvm). Logging in using PuTTY (Windows)
188
189 h3. Initial configuration
190
191 # Open PuTTY from the Start Menu.
192 # On the Session screen set the Host Name (or IP address) to “shell”.
193 # On the Session screen set the Port to “22”.
194 # On the Connection %(rarr)&rarr;% Data screen set the Auto-login username to the username listed in the *logins* column on the Arvados Workbench page _Compute %(rarr)&rarr;% Virtual machines_.
195 # On the Connection %(rarr)&rarr;% Proxy screen set the Proxy Type to “Local”.
196 # On the Connection %(rarr)&rarr;% Proxy screen in the “Telnet command, or local proxy command” box enter:
197 <code>plink -P 2222 turnout@switchyard.qr1hi.arvadosapi.com %host</code>
198 Make sure there is no newline at the end of the text entry.
199 # Return to the Session screen. In the Saved Sessions box, enter a name for this configuration and click Save.
200
201 _Note: We recommend you do not delete the “Default” Saved Session._
202
203 h3. Connecting to the VM
204
205 # Open PuTTY from the Start Menu.
206 # Click on the Saved Session name you created in the previous section.
207 # Click Load to load those saved session settings.
208 # Click Open to open the SSH window at the command prompt. You will now be logged into your virtual machine.
209
210 You should now be able to log into the Arvados VM and "check your environment.":check-environment.html