Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Created October 6, 2020 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruanbekker/ac774d8fbeadc17b5575b43785573d45 to your computer and use it in GitHub Desktop.
Save ruanbekker/ac774d8fbeadc17b5575b43785573d45 to your computer and use it in GitHub Desktop.
Setup a KVM Host on OneProvider

Update and install cpu-checker to see if we can use hardware virtualization:

$ apt update && apt upgrade -y
$ apt install cpu-checker -y

Test with kvm-ok:

$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

On a client pc, generate the ssh key that we will use to authenticate with on our kvm host:

$ ssh-keygen -t rsa -C deploys -f ~/.ssh/deploys.pem

Create the user and prepare the ssh directory:

$ useradd -m -s /bin/bash deploys
$ mkdir /home/deploys/.ssh
$ touch /home/deploys/.ssh/authorized_keys

Copy the public key:

$ cat ~/.ssh/deploys.pem.pub| pbcopy

Paste your public key to the servers authorized_keys file:

# paste into /home/deploys/.ssh/authorized_keys

Set the correct permissions:

$ chown -R deploys:deploys /home/deploys
$ chmod 755 /home/deploys/.ssh
$ chmod 644 /home/deploys/.ssh/authorized_keys

Install kvm:

$ apt install bridge-utils qemu-kvm libvirt-bin virtinst -y

Add user to the libvirt group:

$ usermod -G libvirt deploys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment