-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbasic_shell_logging.html
176 lines (141 loc) · 4.75 KB
/
basic_shell_logging.html
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html>
<html>
<head>
<title>SSH onto a HPC</title>
<meta charset="utf-8">
<meta name="author" content="Alexis Lucattini" />
<link href="libs/remark-css-0.0.1/default.css" rel="stylesheet" />
<link href="libs/remark-css-0.0.1/default-fonts.css" rel="stylesheet" />
</head>
<body>
<textarea id="source">
class: center, middle, inverse, title-slide
# SSH onto a HPC
### Alexis Lucattini
### 2017/08/17
---
# Installing commandline tools (Mac OSX)
### (0 to 10 minutes)
Mac OSX by default does not have command line tools installed.
This is a simple fix as shown [here](http://railsapps.github.io/xcode-command-line-tools.html)
Open up 'Terminal' and type in the following.
```bash
xcode-select -p
```
`/Applications/Apple Dev Tools/Xcode.app/Contents/Developer` shoud appear as the output.
If not, type:
```bash
xcode-select --install
```
You will also need homebrew. Type the following line into terminal.
```bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```
---
# Installing commandline tools (Windows)
### (0 to 10 minutes)
Install [Git Bash](https://gitforwindows.org/).
Open up the Git Bash app.
```bash
# Ensure ssh and ssh-copy-id commands exist
which ssh
which ssh-copy-id
# These two commands should return these two outputs respectively.
/usr/bin/ssh/
/usr/bin/ssh-copy-id
```
---
# SSH into the cluster.
Let's first try and ssh into the cluster. SSH stands for *secure shell login*
```bash
# Use your login credentials to ssh onto the server
ssh <username>@<server_name>
# This should prompt you for your password
```
The following commands will be needed to navigate around:
`pwd, ls, cd`
The following commands will be needed to move and transfer files:
`mv, cp, rm, touch`
You can practise these on your own computer first before trying on the server.
Type `exit` to leave the server and return to your computer.
---
# Passwords are annoying.
Let's use a key so that we don't have to continue entering our password when logging in.
```bash
# Install ssh-copy-id
brew install ssh-copy-id
# Create an ssh-key
ssh-keygen -t rsa # Then press enter twice.
# Now copy ssh key to server, you will be prompted for your password, one last time
ssh-copy-id -i ~/.ssh/id_rsa <username>@<server_name>
# Now try log in.
ssh username@<server_name>
```
---
# Troubleshooting
## I have copied across my id, but it still won't log in automatically.
Try change the permissions on your .ssh folder
```bash
chmod -R 700 ~/.ssh
```
If this still doesn't work, make sure that only you have permissions on your home directory.
View this [Stack-Exchange Thread](https://unix.stackexchange.com/questions/37164/ssh-and-home-directory-permissions) for more details.
---
# Troubleshooting
## I can't install brew or ssh-copy-id (Mac OSX)
That's okay, we can copy our id onto the server
```bash
scp ~/.ssh/id_rsa.pub <username>@<server>:
ssh <username>@<server_name>
# Now we're on the server; Create a .ssh directory for the server
mkdir -p -m 700 ~/.ssh
# Now append that id_rsa.pub key to our list of authorized keys
cat id_rsa.pub >> ~/.ssh/authorized_keys
# Our work here is done. Let's delete the .pub file and leave the server
rm id_rsa.pub
exit
```
---
# Further reading.
### Steve Parker: Shell scripting
Very comprehensive guide to using the 'Terminal'.
Starts at the very basics.
https://www.amazon.com.au/Shell-Scripting-Tutorial-Steve-Parker-ebook/dp/B00C2EGNSA
Free version is here:
https://www.shellscript.sh
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
<script>var slideshow = remark.create({
"highlightStyle": "github",
"highlightLines": true,
"countIncrementalSlides": false
});
if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
window.dispatchEvent(new Event('resize'));
});
(function() {
var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
if (!r) return;
s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
d.head.appendChild(s);
})();</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML';
if (location.protocol !== 'file:' && /^https?:/.test(script.src))
script.src = script.src.replace(/^https?:/, '');
document.getElementsByTagName('head')[0].appendChild(script);
})();
</script>
</body>
</html>