DEV Community

Reishi Mitani
Reishi Mitani

Posted on • Updated on

Preparing cfssl and Docker in EC2 Instance

First, install git in your ec2 instance.

// press y when asked
$ sudo yum install git
$ git version
git version 2.23.3
Enter fullscreen mode Exit fullscreen mode

Go to your ./ssh directory and add your github account.

// type Enter for all the questions
~/.ssh $ ssh-keygen -t rsa -C "my-mailaddress-for-git@mail.com"

~/.ssh $ sudo chmod 600 id_rsa

~/.ssh $ cat id_rsa.pub
// copy the contents and add a new ssh key on github
Enter fullscreen mode Exit fullscreen mode

You are ready to go when you have the following message.

$ ssh -T git@github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
Enter fullscreen mode Exit fullscreen mode

Next, we will have to install golang onto your EC2 instance. -y command stands for assume y if prompted

$ sudo yum install -y golang

// after installed
$ go version
go version go1.13.14 linux/amd64
Enter fullscreen mode Exit fullscreen mode

We will need to add the go path.

// add path
$ vi ~/.bash_profile
// inside .bash_profile

export GOPATH=$HOME/.go
export PATH=$HOME/.go/bin:$PATH

// Exit, and source it
$ source ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

From now, you could follow the instructions in the readme to install cfssl with more information: cfssl readme

$ git clone git@github.com:cloudflare/cfssl.git
$ cd cfssl
$ make
Enter fullscreen mode Exit fullscreen mode

Now we will build the cfssl. Make sure NOT to build in the cfssl repository that you cloned. It will take about a minute to build.

$ go get -u github.com/cloudflare/cfssl/cmd/cfssl
$ cfssl version
Version: dev
Runtime: go1.13.14
Enter fullscreen mode Exit fullscreen mode

We will also install cfssljson just in case. This also takes about a minute to build.

$ go get -u github.com/cloudflare/cfssl/cmd/cfssljson
Enter fullscreen mode Exit fullscreen mode

Finally, let's get Docker installed onto your EC2 instance.

$ sudo yum install -y docker

$ grep -i docker /etc/group
docker:x:990:

$ sudo gpasswd -a ec2-user docker # Use your own username for 'ec2-user'
Adding user username to group docker

$ grep -i docker /etc/group
docker:x:990:username

$ sudo service docker start
Enter fullscreen mode Exit fullscreen mode

Logout first, and login back again. You should be able to use docker now. As for docker-compose, use the following commands.

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
docker-compose version 1.26.2, build eefe0d31
docker-py version: 4.2.2
CPython version: 3.7.7

Enter fullscreen mode Exit fullscreen mode

Top comments (0)