Skip to content

Instantly share code, notes, and snippets.

@Trevoke
Last active June 22, 2016 10:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Trevoke/4480331 to your computer and use it in GitHub Desktop.
Save Trevoke/4480331 to your computer and use it in GitHub Desktop.
Ye Olde Learn Un*x The Hard Way Shortcut

GOAL

Be able to push to Heroku as any of three Heroku users from a single computer and a single user.

For this, you will not be allowed to copy and paste anything - except SSH keys themselves, because we're not THAT evil.

If you get error messages, read them carefully, and make note of what you understand, what you don't understand, and what you think you understand.

SETUP

Create two Linux VMs, with VirtualBox, both on a Host-Only network with VirtualBox.

Brave souls will use two different Linux distributions (not necessary).

Examples: Ubuntu, Slackware, Debian, Gentoo, Arch, RedHat

Here is how you would do it:

  1. Turn off VMs

  2. Go to VB settings

  3. Go to 'Networks'

  4. Add a host-only network, the name should be 'vboxnet0' or something similar.

  5. Edit that network. The IP address should be 192.168.56.1.

-- Go to DHCP Server, set it as 192.168.56.100, netmask 255.255.255.0, lower address bound 192.168.56.101, upper address bound 192.168.56.254

  1. Edit your VMs, go to Networks, add a network adapter with host-only networking and use that host-only network.

  2. In each VM, create three users: alice, bob and charlie, with different passwords (bob and bob can have the same password)

  • No SSH keys
  • No shell configuration (no bashrc, zshrc, oh-my-zsh, etc)
  • RVM with latest Ruby MRI installed
  • Heroku toolbelt installed

We will refer to the VMs as VM1 and VM2.

HEROKU

Log in as alice, then follow these steps. Please note that some of these steps look deceptively short; there is unspoken setup. The unspoken setup is the important part.

  1. Create three email addresses, one for each user.

  2. Create one Heroku account for each user.

  3. Create an app on alice's Heroku account.

  4. Push code as alice. This will require creating an SSH key. Create an SSH key WITH A PASSWORD.

  5. Add bob as a collaborator.

  6. Add charlie as a collaborator.

  7. Push code as bob (this means, 'heroku login' as bob, then try to push).

  8. Push code as charlie.

You'll probably run into some issues right around the time you try to push code as Bob. Make it work manually (do not spend more than 30 minutes on that), then check out the plugin to the heroku toolbelt for multiple heroku accounts.

https://github.com/ddollar/heroku-accounts

Isn't that so nice?

  1. Push code as alice, bob and charlie using the heroku accounts plugin to change which account you are using. Do NOT use the --auto flag to set things up.

Now that you got it working, make a note of coming back here later to examine what you would need to do to make it work manually if you did not figure it out in 30 minutes. Don't worry if you didn't: it's not obvious. Your pride is intact.

SSH

In these exercises, alice@VM1 means "user alice on machine VM1". Pay attention to trying IP address and machine name. Some may work, some may fail.

  1. SSH from alice@VM1 to alice@VM2 (log on with alice on VM1, and from there, ssh to user alice on VM2).

  2. SSH from alice@VM2 to bob@VM2 and charlie@VM2

  3. SSH from alice@VM1 to alice@VM1

  4. SSH from alice@VM1 to bob@VM1

  5. SSH from bob@VM1 to bob@VM2

  6. SSH from bob@VM2 to bob@VM1 BUT! Create the ssh key files on bob@VM2 manually (touch, vim, whatever) and copy the content of the key files from bob@VM1 into bob@VM2.

5,6,7,8) Repeat steps 1-4 using the method you discovered with the heroku accounts plugin.

9,10,11,12) Clear solution from previous step. Repeat steps 1-4 using ssh-agent.

13,14,15,16) Clear solution from previous step. Repeat steps 1-4 with SSH certificates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment