Setting up SSH Keys Using Cloud Config

Setting up SSH Keys Using Cloud Config

In this tutorial we’ll cover setting up SSH keys with cloud config. You can find general cloud config usage examples here: https://cloudinit.readthedocs.io/en/latest/reference/examples.html Cloud config uses yaml syntax. This tutorial assumes you have generated an ssh private – public key pair. If not you can find how to generate an ssh key pair in the beginning of this tutorial here: https://systemweakness.com/setup-ssh-keys-a8ca650309b3

Setting up SSH Keys Using Cloud Config

This command packs the punch: 

							
							
					#cloud-config
users:
  - name: myusername
    ssh-authorized-keys:
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDxC1...your-public-key... user@hostname
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    shell: /bin/bash
				
			
  • name: This is the users username
  • ssh-authorized-keys: This is the ssh public key
  • sudo: This specifies which sudo privileges the user has, here hwe have specified ALL. We have also disabled the password when running sudo. Basically the user can run as sudo on all hosts, impersonate all other users and run all commands with sudo.
  • shell: This assigns the default shell to the user being created. 

That’s a wrap! 

Walter Miely is a tech entrepreneur and CEO of Phoenix Ignited Tech You can find him on Linkedin. This material is licensed under the CC BY 4.0 License LEGAL DISCLAIMER: The content provided here is provided AS IS, and part of, or the entirety of this content may be incorrect. Please read the entireLegal Disclaimer here.