cc_staff
1,486
edits
Line 61: | Line 61: | ||
There are a number of ways to approach this, but basically what is needed is to add another public ssh key to the VM (see [[ssh keys]] about working with and creating keys). This could be done by adding to the <code>authorized_keys</code> of the primary user account provided for the VM, usually named after the operating system, or it could be added to a newly created user account. In Ubuntu, when logged in with the primary user's account this can be accomplished with the command <code>sudo adduser USERNAME</code>. Then add the supplied public key to that users <code>.ssh/authorized_keys</code> file as described in [[ssh keys]] and linked pages. | There are a number of ways to approach this, but basically what is needed is to add another public ssh key to the VM (see [[ssh keys]] about working with and creating keys). This could be done by adding to the <code>authorized_keys</code> of the primary user account provided for the VM, usually named after the operating system, or it could be added to a newly created user account. In Ubuntu, when logged in with the primary user's account this can be accomplished with the command <code>sudo adduser USERNAME</code>. Then add the supplied public key to that users <code>.ssh/authorized_keys</code> file as described in [[ssh keys]] and linked pages. | ||
Another alternative would be to do this during the creation of your VM using [http://cloudinit.readthedocs.org/en/latest/index.html# CloudInit]. The following | Another alternative would be to do this during the creation of your VM using [http://cloudinit.readthedocs.org/en/latest/index.html# CloudInit]. The following CloudInit script (which uses the YAML format, see [http://www.yaml.org/spec/1.2/spec.html#Preview YAML Preview]): | ||
#cloud-config | #cloud-config | ||
Line 75: | Line 75: | ||
- <Insert public key> | - <Insert public key> | ||
adds two users <code>sysadmin</code> and <code>user</code> with and without sudo permissions respectively. The <code><Insert public key></code> must be replaced with the public key to use for that user. After the VM has finished spawning, take a look at the log to ensure that the public keys have been added correctly for those users. The log should show something like: | adds two users <code>sysadmin</code> and <code>user</code> with and without sudo permissions respectively. The <code><Insert public key></code> must be replaced with the public key to use for that user. After the VM has finished spawning, take a look at the log to ensure that the public keys have been added correctly for those users. The log can be found by click the name of the instance under the "Compute->Instances" panel and then selecting the "log" tab. The log should show something like: | ||
ci-info: ++++++++Authorized keys from /home/sysadmin/.ssh/authorized_keys for user sysadmin++++++++ | ci-info: ++++++++Authorized keys from /home/sysadmin/.ssh/authorized_keys for user sysadmin++++++++ |