-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashCheatSheet.Rmd
95 lines (65 loc) · 2.61 KB
/
bashCheatSheet.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
title: "bash Cheat Sheet"
author: "Anthony Atto"
output:
html_document:
code_folding: hide
toc: true
toc_float:
collapsed: false
md_extensions: +raw_html
---
```{r setup, warning=FALSE, message=FALSE}
# set knitr options
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
require(remoji)
require(htmltools)
```
## Overview
This is a document I created to help me remember some key commands and uses for BASH.
## Basics
### Philosophy
command. options. arguments.
### Navigation
* `cd`
* `ls`
* `cat`
* `echo`
### Help
### Profiles
## `r HTML(paste("Major", emoji("key")))`
### cron
* `crontab`
* `-e`, `-l`
## SSH & Key Management
### Generate a Key
> `ssh-keygen -t rsa`
This generates both a public and private key
### .ssh Folder Location
> `/Users/ARA/.ssh`
This directory is hidden in the users home directory. the `.` hides it in the finder and will not be shown with just the `ls` command. `ls -a` must be used to show hidden files.
### Copy a Key to the Server
#### Linux
> `ssh-copy-id user@server.com`
Copying keys on a Linux machine is easy. It will automatically put the public key in the server's .ssh folder for you.
#### Mac
Mac is more complicated. You have to copy a key to the server, then move the key into the .ssh directory.
1. Use Secure Copy
> `scp [key location] user@server.com:`
Use secure copy to send the public key to the server. An example: `scp .ssh/id_rsa.pub anthony@anthonyatto.com:`. Be sure to include the `:` at the end of the line.
2. Log Into Server
> `ssh [user@server.com]`
SSH into the server so that you can then move the public key to the right place yourself. An example: `ssh anthony@anthonyatto.com`. You will likely be prompted for a password (or will automatically be logged in if you have a keypair set up).
3. Store the Public Key in `authorized_keys`
> `mkdir ~/.ssh`
`cat id_rsa.pub > .ssh/authorized_keys`
Check that the public key is where you expected it to be (in `$HOME`). If one is not already there, create an `.ssh` directory. Then, move the public key to `.ssh/authorized_keys`.
### Connect to the Server using Key
> `ssh -i [private key location] [user@server.com]`
Connects after matching private key on local host and public key on server. An example: `ssh - i ~/.ssh/id_rsa anthony@anthonyatto.com`. The `-i` option tells `ssh` to 'identify' the public key on the server.
### SSH Shortcut
> `Host anthony`
> ` User anthony`
> ` Hostname anthonyatto.com`
> ` IdentityFile ~/.ssh/id_rsa`
then, simply type `ssh anthony` and it will login automatically.