1
0
mirror of https://github.com/tiyn/wiki.git synced 2025-11-27 05:39:45 +01:00

ssh: improved structure and linking

This commit is contained in:
2025-11-23 09:10:38 +01:00
parent 4a91f12dcd
commit 9f162704d1
3 changed files with 37 additions and 10 deletions

View File

@@ -48,12 +48,13 @@ git ls-files -v | grep "^S"
Authentication by default is done via a username and a password. Authentication by default is done via a username and a password.
For some services such as GitHub. For some services such as GitHub.
it is not possible to use password as an authentication method. it is not possible to use password as an authentication method.
The other possibility to authenticate to git is by using The other possibility to authenticate to git is by using [SSH](/wiki/ssh.md).
[SSH](/wiki/linux/ssh.md).
The following sections assumes using a [Linux-based system](/wiki/linux.md) using
[OpenSSH](/wiki/linux/openssh.md).
For this a For this a
[SSH certificate has to be created](/wiki/linux/ssh.md#generate-new-keys) and [SSH certificate has to be created](/wiki/linux/openssh.md#generate-new-keys) and
[added to the authentication agent](/wiki/linux/ssh.md#adding-keys-to-authentication-agent). [added to the authentication agent](/wiki/linux/openssh.md#adding-keys-to-authentication-agent).
Afterwards it the public SSH key to be added to the git server. Afterwards it the public SSH key to be added to the git server.
For GitHub there is For GitHub there is
[a guide on that topic](https://docs.github.com/en/get-started/getting-started-with-git/why-is-git-always-asking-for-my-password). [a guide on that topic](https://docs.github.com/en/get-started/getting-started-with-git/why-is-git-always-asking-for-my-password).
@@ -71,7 +72,7 @@ git clone https://github.com/tiyn/wiki
By using the SSH config file the clone command can be shortened to By using the SSH config file the clone command can be shortened to
`git clone github:tiyn/wiki`. `git clone github:tiyn/wiki`.
For this follow the For this follow the
[corresponding section in the SSH entry](/wiki/linux/ssh.md#shorten-ssh-connection-commands). [corresponding section in the SSH entry](/wiki/linux/openssh.md#shorten-ssh-connection-commands).
Set `Host` to `github`, `HostName` to `github.com` and `User` to `git`. Set `Host` to `github`, `HostName` to `github.com` and `User` to `git`.
### Improved `git diff` ### Improved `git diff`

View File

@@ -1,10 +1,11 @@
# SSH # OpenSSH
SSH is a network protocoll to securely connect to a computer. [OpenSSH](https://www.openssh.com) is an implementation of the [SSH protocol](/wiki/ssh.md).
In this article it is assumed that `openssh` is used.
## Usage ## Usage
This section addresses the usage of OpenSSH.
### Generate New Keys ### Generate New Keys
To generate new ssh keys simply run `ssh-keygen -t ed25519` or To generate new ssh keys simply run `ssh-keygen -t ed25519` or
@@ -35,15 +36,30 @@ to `PermitRootLogin yes`.
To enable easy login without password you can add the contents of the file To enable easy login without password you can add the contents of the file
`~/.ssh/id_rsa.pub` from your local machine to the file `~/.ssh/authorized_keys` `~/.ssh/id_rsa.pub` from your local machine to the file `~/.ssh/authorized_keys`
on the machine you want to log into. on the machine you want to log into.
You can use the modified command below for ease of use:
There are two options to add the public key to the remote machine.
The first is a more manual approach.
`<path-to-public-key>` is the path to the public key (for example `~/.ssh/id_rsa.pub`) and `<host>`
is the (user and) server to add the key to (for example `user@192.168.178.16`).
```sh ```sh
cat ~/.ssh/id_rsa.pub | ssh username@server 'cat >> ~/.ssh/authorized_keys' cat <path-to-public-key> | ssh <host> 'cat >> ~/.ssh/authorized_keys'
``` ```
This can also be more or less fully automated using the `-G` flag of SSH as described in This can also be more or less fully automated using the `-G` flag of SSH as described in
[a YouTube video by nixhero](https://www.youtube.com/watch?v=xCX14u9XzE8). [a YouTube video by nixhero](https://www.youtube.com/watch?v=xCX14u9XzE8).
The second option is a bit safer, due to using OpenSSHs tools, was described in a
[StackOverflow comment by Boy](https://stackoverflow.com/questions/18690691/how-to-add-a-ssh-key-to-remote-server).
It functions similar to the first and uses the following command.
```sh
ssh-copy-id -f -i <path-to-public-key> <host>
```
The `-f` flag can alos be omittet to check if the key is already installed.
For being very safe is important, a dry run can be performed using the `-n` flag.
### Mount Directory With SSHFS ### Mount Directory With SSHFS
This section is loosely based on This section is loosely based on

10
wiki/ssh.md Normal file
View File

@@ -0,0 +1,10 @@
# SSH
SSH is a network protocoll to securely connect to a computer.
## Implementations
There are various implementations of the SSH protocol.
- [OpenSSH](/wiki/linux/openssh.md) is an SSH implementation for
[Linux-based systems](/wiki/linux.md).