From 9f162704d1102a7b167c109087cecc324bc95085 Mon Sep 17 00:00:00 2001 From: tiyn Date: Sun, 23 Nov 2025 09:10:38 +0100 Subject: [PATCH] ssh: improved structure and linking --- wiki/linux/git_(package).md | 11 ++++++----- wiki/linux/{ssh.md => openssh.md} | 26 +++++++++++++++++++++----- wiki/ssh.md | 10 ++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) rename wiki/linux/{ssh.md => openssh.md} (83%) create mode 100644 wiki/ssh.md diff --git a/wiki/linux/git_(package).md b/wiki/linux/git_(package).md index f5ffb89..17a3149 100644 --- a/wiki/linux/git_(package).md +++ b/wiki/linux/git_(package).md @@ -48,12 +48,13 @@ git ls-files -v | grep "^S" Authentication by default is done via a username and a password. For some services such as GitHub. it is not possible to use password as an authentication method. -The other possibility to authenticate to git is by using -[SSH](/wiki/linux/ssh.md). +The other possibility to authenticate to git is by using [SSH](/wiki/ssh.md). +The following sections assumes using a [Linux-based system](/wiki/linux.md) using +[OpenSSH](/wiki/linux/openssh.md). For this a -[SSH certificate has to be created](/wiki/linux/ssh.md#generate-new-keys) and -[added to the authentication agent](/wiki/linux/ssh.md#adding-keys-to-authentication-agent). +[SSH certificate has to be created](/wiki/linux/openssh.md#generate-new-keys) and +[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. 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). @@ -71,7 +72,7 @@ git clone https://github.com/tiyn/wiki By using the SSH config file the clone command can be shortened to `git clone github:tiyn/wiki`. 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`. ### Improved `git diff` diff --git a/wiki/linux/ssh.md b/wiki/linux/openssh.md similarity index 83% rename from wiki/linux/ssh.md rename to wiki/linux/openssh.md index 6f5f9cb..2d40ecc 100644 --- a/wiki/linux/ssh.md +++ b/wiki/linux/openssh.md @@ -1,10 +1,11 @@ -# SSH +# OpenSSH -SSH is a network protocoll to securely connect to a computer. -In this article it is assumed that `openssh` is used. +[OpenSSH](https://www.openssh.com) is an implementation of the [SSH protocol](/wiki/ssh.md). ## Usage +This section addresses the usage of OpenSSH. + ### Generate New Keys 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 `~/.ssh/id_rsa.pub` from your local machine to the file `~/.ssh/authorized_keys` 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. +`` is the path to the public key (for example `~/.ssh/id_rsa.pub`) and `` +is the (user and) server to add the key to (for example `user@192.168.178.16`). ```sh -cat ~/.ssh/id_rsa.pub | ssh username@server 'cat >> ~/.ssh/authorized_keys' +cat | ssh 'cat >> ~/.ssh/authorized_keys' ``` 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). +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 +``` + +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 This section is loosely based on diff --git a/wiki/ssh.md b/wiki/ssh.md new file mode 100644 index 0000000..f402387 --- /dev/null +++ b/wiki/ssh.md @@ -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).