fixed markup for code
This commit is contained in:
parent
925eaf2f9e
commit
6e18636609
@ -37,9 +37,12 @@ How-To
|
||||
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.
|
||||
|
||||
First, we will generate a SSH_ key pair, with or without password to protect it
|
||||
:
|
||||
``ssh-keygen -f new_key``
|
||||
First, we will generate a SSH_ key pair, with or without password to protect it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ssh-keygen -f new_key
|
||||
|
||||
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
|
||||
part. We don't have to check what's inside the private key, since it's randomly
|
||||
@ -48,49 +51,66 @@ 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
|
||||
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
|
||||
|
||||
Just enter your password, and it should be done. The program should output :
|
||||
``Number of key(s) added: 1``
|
||||
ssh-copy-id -i new_key root@nasa.gov
|
||||
|
||||
Just enter your password, and it should be done. The program should output:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
Number of key(s) added: 1
|
||||
|
||||
This means that you succeeded! (You can now disable SSH password login on the remote
|
||||
server, huh)
|
||||
|
||||
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
|
||||
it :
|
||||
``eval $(ssh-agent)
|
||||
ssh-add ./new_key``
|
||||
it:
|
||||
|
||||
This program should output :
|
||||
``Identity added: new_key (user@hostname)``
|
||||
.. code-block:: bash
|
||||
|
||||
We then need to add some ssh client configuration, to make it automatized.
|
||||
eval $(ssh-agent)
|
||||
ssh-add ./new_key
|
||||
|
||||
``Host *.freepoteries.fr
|
||||
ForwardAgent yes
|
||||
User user
|
||||
IdentityFiles ~/new_key``
|
||||
This program should output:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
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
|
||||
User user
|
||||
IdentityFiles ~/new_key
|
||||
|
||||
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
|
||||
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
|
||||
session (read `man ssh-agent` for further information):
|
||||
Save all of this in **~/.ssh/config**.
|
||||
|
||||
``if [[ "$SSH_AGENT_PID" == "" ]]; then
|
||||
eval "$(<~/.run/ssh-agent/environment)"
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
ssh-add ~/.ssh/id_rsa_ma-otec
|
||||
ssh-add ~/.ssh/id_rsa_belugaspot-msleaveamix
|
||||
fi``
|
||||
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)"
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
ssh-add ~/.ssh/id_rsa_ma-otec
|
||||
ssh-add ~/.ssh/id_rsa_belugaspot-msleaveamix
|
||||
fi
|
||||
|
||||
|
||||
.. _Secure SHell: https://www.ssh.com/ssh
|
||||
|
||||
Loading…
Reference in New Issue
Block a user