1 of 26

CAPP Development Module

Workflow Speedups

Review of Basic Commands

Common Programs/Functions

Bash Scripting & Common Operators

Paths

Remote Shells & APIs

Virtual Python Environments

2 of 26

Tonight’s demo repo:

https://github.com/justincohler/capp_dev_module

3 of 26

Speed up your workflow

4 of 26

  • Tab-to-complete
  • Line endings: ctrl-a, ctrl-e
  • Home (~)
  • Wildcards (*)
  • Last command (!!)

Practice incorporating during the lab!

```

```

5 of 26

Getting around via CLI

6 of 26

  • ls <path> -- list directory
  • pwd -- present working directory
  • cd <path> -- change directory
  • cp <from> <to> -- copy file/folder
  • mv <from> <to> -- move/rename
  • mkdir <name> -- make directory

```

7 of 26

Common Functions

8 of 26

  • Viewing files: head, tail, cat
  • Writing/Appending: >, >>
  • Creating empty file: touch
  • Method chaining: |
  • Killing hung processes: kill

```

9 of 26

Bash Scripting

10 of 26

  • Script heading:
    • #!/bin/bash
  • Variables:
    • MY_VAR=123
  • If/Else Statements: if [case]; then/fi
  • Loops: for/done for <case>; do/done

```

11 of 26

Paths

12 of 26

  • Exporting variables
  • The main “PATH” variable
  • Bash Profiles
  • /tmp, /opt, and /usr/local

```

13 of 26

SSH Configuration

14 of 26

What is SSH and where is it useful?

A trust-based remote access system

(used in AWS and clouds everywhere)

15 of 26

What do you need to connect via SSH?

16 of 26

  • Private Key (e.g. id_rsa)
  • Public Key (e.g. id_rsa.pub)
  • The same Public Key stored in the host’s authorized_keys file

17 of 26

Why public AND private keys?

18 of 26

Diffy-Hellman

19 of 26

Demo Time:

Create a new key if you don’t already have one with:

  • ssh-keygen (mac & linux)
  • PuTTy (windows)

20 of 26

A very basic ssh call:

$> ssh -i <private-key-path> <user>@<host>

On our demo ec2 instance (AWS):

21 of 26

Why will this not work when you attempt the same command with your private key?

22 of 26

The host only allows those whose public key is on the list in ~/.ssh/authorized_keys

23 of 26

For frequent ssh remoting to different instances, the ~/.ssh/config is a useful shorthand

24 of 26

Host capp-demo

User ec2-user

Hostname ec2-54-82-235-131.compute-1.amazonaws.com

IdentityFile ~/.ssh/aws-ec2.pem

25 of 26

Now, we can just remote in by our nickname:

ssh capp-demo

26 of 26

wowowowowow