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
|
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,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
|
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
|
||||||
|
|
||||||
Just enter your password, and it should be done. The program should output :
|
ssh-copy-id -i new_key root@nasa.gov
|
||||||
``Number of key(s) added: 1``
|
|
||||||
|
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
|
This means that you succeeded! (You can now disable SSH password login on the remote
|
||||||
server, huh)
|
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``
|
|
||||||
|
|
||||||
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.
|
eval $(ssh-agent)
|
||||||
|
ssh-add ./new_key
|
||||||
|
|
||||||
``Host *.freepoteries.fr
|
This program should output:
|
||||||
ForwardAgent yes
|
|
||||||
User user
|
.. code-block:: bash
|
||||||
IdentityFiles ~/new_key``
|
|
||||||
|
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
|
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
|
||||||
eval "$(<~/.run/ssh-agent/environment)"
|
session (read **man ssh-agent** for further information):
|
||||||
ssh-add ~/.ssh/id_rsa
|
|
||||||
ssh-add ~/.ssh/id_rsa_ma-otec
|
.. code-block:: bash
|
||||||
ssh-add ~/.ssh/id_rsa_belugaspot-msleaveamix
|
|
||||||
fi``
|
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
|
.. _Secure SHell: https://www.ssh.com/ssh
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user