Skip to content

Commit 1f54c43

Browse files
committed
update SSH
1 parent f0384f5 commit 1f54c43

File tree

7 files changed

+110
-55
lines changed

7 files changed

+110
-55
lines changed

data/server/index.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ ifconfig
1111

1212
## Login to Server
1313
> logout SSH `exit`
14-
```txt
14+
```bash
15+
# test connection
16+
17+
1518
1619

1720
# run bash on remote server

data/server/ssh/certificates.md

-4
This file was deleted.

data/server/ssh/index.md

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
[SSH Audit](ssh-audit.com)
2+
3+
14
## generate key
25
> if you want to change the key name make sure to put the full directory path
36
```bash
4-
cd ~/.ssh/
5-
ssh-keygen -t ecdsa -b 521 -C "[email protected]"
7+
ssh-keygen -t ed25519 -C "[email protected]"
68

7-
# old
8-
ssh-keygen -t rsa -b 4096 -C "[email protected]"
9+
ssh-keygen -t rsa -b 4096 -C "[email protected]"
10+
11+
# -t ed25519 : EdDSA performs much faster and provides the same level of security with significantly smaller keys
12+
# -t rsa : old - universally supported
13+
# -t dsa : Just don’t use ECDSA/DSA!
14+
# -t ecdsa : Just don’t use ECDSA/DSA!
915
```
1016

1117

@@ -34,19 +40,6 @@ cat ~/.ssh/authorized_keys
3440
```
3541

3642

37-
## settings
38-
> make sure to restart sshd `sudo systemctl restart sshd`
39-
40-
`sudo nano /etc/ssh/sshd_config`
41-
```bash
42-
# ...
43-
PubkeyAuthentication yes
44-
# PermitRootLogin [no|yes|prohibit-password|without-password]
45-
# PasswordAuthentication yes
46-
# ...
47-
```
48-
49-
5043
## Copy files
5144
```bash
5245
scp ~/local.txt [email protected]:~/remote/q

data/server/ssh/install.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
## install ssh server
22
```txt
33
sudo apt install -y openssh-server
4-
4+
sudo systemctl enable ssh
55
sudo systemctl status ssh
6-
```
7-
86
9-
## setup ssh
10-
```txt
117
mkdir ~/.ssh/
128
chmod 700 ~/.ssh/
139
@@ -16,8 +12,9 @@ chmod 600 ~/.ssh/*
1612
```
1713

1814

19-
## systemd
15+
## logs
2016
```
21-
sudo systemctl enable ssh
22-
sudo systemctl status ssh
17+
journalctl -u ssh
18+
19+
journalctl -b -u ssh
2320
```

data/server/ssh/manual.md

-18
This file was deleted.

data/server/ssh/other.md

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,52 @@
1-
## testing
2-
testing SSH connection
3-
```txt
4-
1+
## Get fingerprint
2+
```bash
3+
ssh-keygen -l -f ~/.ssh/id_ed25519
4+
# 256 SHA256:KHzEcaes5BlSwvrhbVOs7QTNbL2J3ZD4c7rIkyun4+0 test-1 (ED25519)
5+
6+
ssh-keygen -l -f ~/.ssh/id_ed25519.pub
7+
# 256 SHA256:KHzEcaes5BlSwvrhbVOs7QTNbL2J3ZD4c7rIkyun4+0 test-1 (ED25519)
58
```
69

10+
711
## ssh config
812
change SSH port number
913
`sudo nano ~/.ssh/config`
10-
```txt
14+
```bash
1115
Host github.com
1216
Hostname ssh.github.com
1317
Port 443
1418
```
1519

1620

17-
18-
1921
## !!!
2022
```txt
2123
# Start the ssh-agent in the background
2224
eval "$(ssh-agent -s)"
2325
ssh-add ./.ssh/id_rsa
2426
```
27+
28+
## Manual
29+
> `man ssh-keygen`
30+
> `man ssh_config`
31+
32+
33+
```txt
34+
-q Silence ssh-keygen.
35+
-t Specifies the type of key to create. [dsa|ecdsa|ed25519|rsa]
36+
-f filename Specifies the filename of the key file.
37+
```
38+
39+
40+
## certificates
41+
```txt
42+
-s ca_key Certify (sign) a public key using the specified CA key.
43+
-I certificate_identity Specify the key identity when signing a public key.
44+
-h When signing a key, create a host certificate instead of a user certificate.
45+
```
46+
47+
48+
# !!!
49+
```bash
50+
ssh-keygen -s /path/to/ca_key -I key_id /path/to/user_key.pub
51+
ssh-keygen -s /path/to/ca_key -I key_id -h /path/to/host_key.pub
52+
```

data/server/ssh/settings.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[SSH Audit](ssh-audit.com)
2+
3+
4+
## edit sshd
5+
```bash
6+
sudo nano /etc/ssh/sshd_config
7+
8+
# restart sshd
9+
sudo systemctl restart sshd
10+
```
11+
12+
13+
## best
14+
```bash
15+
Port 2222
16+
PasswordAuthentication no
17+
PermitEmptyPasswords no
18+
PermitRootLogin no
19+
UsePAM no
20+
```
21+
22+
23+
## Disable Passwords
24+
```bash
25+
# To disable tunneled clear text passwords, change to no here!
26+
PasswordAuthentication no
27+
PermitEmptyPasswords no
28+
```
29+
30+
31+
## PM
32+
```bash
33+
# Set this to 'yes' to enable PAM authentication, account processing,
34+
# and session processing. If this is enabled, PAM authentication will
35+
# be allowed through the KbdInteractiveAuthentication and
36+
# PasswordAuthentication. Depending on your PAM configuration,
37+
# PAM authentication via KbdInteractiveAuthentication may bypass
38+
# the setting of "PermitRootLogin without-password".
39+
# If you just want the PAM account and session checks to run without
40+
# PAM authentication, then enable this but set PasswordAuthentication
41+
# and KbdInteractiveAuthentication to 'no'.
42+
UsePAM no
43+
```
44+
45+
46+
## Disallow Root Login
47+
```bash
48+
PermitRootLogin no
49+
```
50+
51+
52+
## Change Port
53+
[List of TCP ports](https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers)
54+
```bash
55+
Port 2222
56+
```

0 commit comments

Comments
 (0)