2020-06-12 19:51:21 +00:00
|
|
|
# [OpenSSH](https://www.openssh.com/)
|
|
|
|
|
2020-12-01 16:10:02 +00:00
|
|
|
| Distribution | Package |
|
|
|
|
| ------------ | ------------------------------- |
|
|
|
|
| Arch Linux | `openssh` |
|
|
|
|
| Ubuntu | `openssh-client openssh-server` |
|
|
|
|
| Ubuntu | `openssh` |
|
2020-06-12 19:51:21 +00:00
|
|
|
|
|
|
|
Edit `~/.ssh/config`:
|
|
|
|
|
|
|
|
```txt
|
|
|
|
Host myserver
|
|
|
|
Hostname server-address
|
|
|
|
User user
|
|
|
|
Port port
|
|
|
|
IdentityFile /path/to/private/key
|
|
|
|
```
|
|
|
|
|
|
|
|
Connect:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ssh -p port user@server-address
|
|
|
|
ssh myserver
|
|
|
|
```
|
|
|
|
|
|
|
|
## SSH key
|
|
|
|
|
2020-07-13 04:19:33 +00:00
|
|
|
Remove keys in `known_hosts`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Remove all
|
|
|
|
rm -rf ~/.ssh/known_hosts
|
|
|
|
|
|
|
|
# Remove only 1
|
|
|
|
ssh-keygen -R remote_host
|
|
|
|
```
|
|
|
|
|
|
|
|
### Copy local key to server
|
|
|
|
|
2020-06-12 19:51:21 +00:00
|
|
|
Generate key:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ssh-keygen -t rsa -b 4096 -C "your@email.com"
|
|
|
|
```
|
|
|
|
|
2020-07-13 04:19:33 +00:00
|
|
|
Start `ssh-agent`:
|
2020-06-12 19:51:21 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
eval "$(ssh-agent -s)"
|
|
|
|
```
|
|
|
|
|
|
|
|
Add key:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ssh-add ~/.ssh/id_rsa
|
|
|
|
```
|
|
|
|
|
|
|
|
Confirm key has been added:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ssh-add -l
|
|
|
|
```
|
|
|
|
|
|
|
|
Copying public key to server:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server-address
|
|
|
|
```
|