1
1

fixed markup for code

This commit is contained in:
maxime 2019-09-09 17:02:10 +02:00
parent 925eaf2f9e
commit 6e18636609

View File

@ -37,9 +37,12 @@ How-To
This how-to will use ssh, ssh-agent, ssh-keygen, netcat and of course our This how-to will use ssh, ssh-agent, ssh-keygen, netcat and of course our
beloved bash to show how to simply authenticate to any SSH_ or Git_ server. beloved bash to show how to simply authenticate to any SSH_ or Git_ server.
First, we will generate a SSH_ key pair, with or without password to protect it First, we will generate a SSH_ key pair, with or without password to protect it:
:
``ssh-keygen -f new_key`` .. code-block:: bash
ssh-keygen -f new_key
This command created two files : new_key and new_key.pub This command created two files : new_key and new_key.pub
The first one is the private part of the pair, and the ".pub" one is the public The first one is the private part of the pair, and the ".pub" one is the public
part. We don't have to check what's inside the private key, since it's randomly part. We don't have to check what's inside the private key, since it's randomly
@ -48,12 +51,17 @@ that will authenticate only and only if it matches with the private one.
Choose a server on which you have an user access with an SSH_ password. For Choose a server on which you have an user access with an SSH_ password. For
example, "nasa.gov". We will copy the newly created public key to it, and allow example, "nasa.gov". We will copy the newly created public key to it, and allow
the autentication with it. the autentication with it:
``ssh-copy-id -i new_key root@nasa.gov`` .. code-block:: bash
ssh-copy-id -i new_key root@nasa.gov
Just enter your password, and it should be done. The program should output: Just enter your password, and it should be done. The program should output:
``Number of key(s) added: 1``
.. code-block:: bash
Number of key(s) added: 1
This means that you succeeded! (You can now disable SSH password login on the remote This means that you succeeded! (You can now disable SSH password login on the remote
server, huh) server, huh)
@ -61,36 +69,48 @@ server, huh)
SSH-Agent_ is like a keyring, it will register your keys to your session, and SSH-Agent_ is like a keyring, it will register your keys to your session, and
will automate the authentication process when needing them. This is how you use will automate the authentication process when needing them. This is how you use
it: it:
``eval $(ssh-agent)
ssh-add ./new_key`` .. code-block:: bash
eval $(ssh-agent)
ssh-add ./new_key
This program should output: This program should output:
``Identity added: new_key (user@hostname)``
We then need to add some ssh client configuration, to make it automatized. .. code-block:: bash
``Host *.freepoteries.fr Identity added: new_key (user@hostname)
We then need to add some ssh client configuration, to make it automatized:
.. code-block:: bash
Host \*.freepoteries.fr
ForwardAgent yes ForwardAgent yes
User user User user
IdentityFiles ~/new_key`` IdentityFiles ~/new_key
If you want to allow users to login directly to machines in the local network of If you want to allow users to login directly to machines in the local network of
your remote host (as it is done with every virtual machine of my server). You your remote host (as it is done with every virtual machine of my server). You
can also add to the options of the host: can also add to the options of the host:
``ProxyCommand ssh user@freepoteries.fr "-q0 %h %p" 2> /dev/null`` .. code-block:: bash
Save all of this in ``~/.ssh/config``. ProxyCommand ssh user@freepoteries.fr "-q0 %h %p" 2> /dev/null
Put this in your ``~/.bashrc`` if you want to make the ssh-agent run at each Save all of this in **~/.ssh/config**.
session (read `man ssh-agent` for further information):
``if [[ "$SSH_AGENT_PID" == "" ]]; then Put this in your **~/.bashrc** if you want to make the ssh-agent run at each
session (read **man ssh-agent** for further information):
.. code-block:: bash
if [[ "$SSH_AGENT_PID" == "" ]]; then
eval "$(<~/.run/ssh-agent/environment)" eval "$(<~/.run/ssh-agent/environment)"
ssh-add ~/.ssh/id_rsa ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa_ma-otec ssh-add ~/.ssh/id_rsa_ma-otec
ssh-add ~/.ssh/id_rsa_belugaspot-msleaveamix ssh-add ~/.ssh/id_rsa_belugaspot-msleaveamix
fi`` fi
.. _Secure SHell: https://www.ssh.com/ssh .. _Secure SHell: https://www.ssh.com/ssh