This page has been translated from Spanish

...::: Guatewireless.org ::::..

Technology, Software Libre, Guatemala, Open Source, Linux, Wireless, WiFi, Scripting, Debian, CentOS, Gentoo, Redhat, SuSE, Windows

Synchronizing with OpenSSH - How to create and configure a public key in Linux

Setting up a public key

First of all, regardless if our Linux is a Debian, Red Hat, SuSe, etc, we must ensure that OpenSSH is the SSH application installed on the client system. The key generation varies under different SSH implementation. The command ssh-V should display a line containing OpenSSH, followed by other details

  mail: ~ # ssh-V
 OpenSSH_4.3p2 Debian-9, OpenSSL 0.9.8c 05 Sep 2006

Generation of the Key

The RSA key pair must be generated on the client system. The public part of this key will be stored on servers to which we connect, while the private key must be stored in a secure area of the client system, by default in ~ / .ssh / id_rsa.

The key pair generation can be done with the ssh-keygen (1).

  fher98 @ deathbian: ~ $ mkdir ~ /. ssh
 fher98 @ deathbian: ~ $ chmod 700 ~ /. ssh
 fher98 @ deathbian: ~ $ ssh-keygen-q-f ~ / .ssh / id_rsa-t rsa
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:

Do not use as your user password passphrase or leave it blank. The password should be at least 16 characters long, and not a simple prayer. A good option is a paragraph of any song or poem, using all possible grammatical symbols. During the configuration of ssh-agent will reduce the revenues required for the password, so we recommend using a long passphrase.

The file permissions must ensure that other users can not read data from the key pair. You may not permit the use OpenSSH public key authentication if the file permissions are not sure. These changes must be made on all systems involved.

  fher98 @ deathbian: ~ $ chmod go-w ~ /
 fher98 @ deathbian: ~ $ chmod 700 ~ /. ssh
 fher98 @ deathbian: ~ $ chmod go-rwx ~ /. ssh / *

Distribution key

The public part of RSA key pair must be copied to all servers that will be accessed by the client. The information of public key to be copied can be found in the ~ / .ssh / id_rsa.pub client. Assuming that all servers use OpenSSH instead of other different implementations of SSH public key must be added to the file ~ / .ssh / authorized_keys in each server.

Copy the public key from client to server

  fher98 @ deathbian: ~ $ scp ~ / .ssh / id_rsa.pub servidor.guatewireless.org:

 id_rsa.pub 100% 395 0.4KB / s 00:00

Now the public key is configured on the server

  server $ mkdir ~ /. ssh
 server $ chmod 700 ~ /. ssh
 server $ cat ~ / id_rsa.pub>> ~ / .ssh / authorized_keys
 server $ chmod 600 ~ / .ssh / authorized_keys
 server $ rm ~ / id_rsa.pub

Remember that you need to add new data from public keys in authorized_keys file, so you can use multiple public keys on the same server. Each record of public key must be on a different line of the file.

To verify that connections to the server public keys are working properly engage in the following test;
From client

  fher98 @ deathbian: ~ $ ssh-o PreferredAuthentications = publickey servidor.guatewireless.org
 Enter passphrase for key '/ ï ¿½ / .ssh / id_rsa': ï ¿½
 ï ¿½
 server $

In a future article will show you how to configure ssh-agent process.

Popularity: 13%



Tagged as:

2 Comments

  1. Thanks for your article, I found it quite good and I have implemented the service with one of my machines ... it has worked perfectly. As you might make a loggin automatically using the same concept ... keeping in mind that if you copy your key, there will be a serious security problem which is solved by generating another key and authorized_keys erasing earlier.

    The article by ssh-agent, do not have it yet?

    Greetings and thanks once again.

    • Ricardo:

      I am pleased that you have served the article. It's a big problem if you steal the key, why must you well protected on your system to someone else not using it.

      Still do not have the ssh-agent, but since you're interested in what you have for this week, we?

      greetings! and thanks for reading

Please enter a comment

Please note the following:
Comments are moderated, so it can take in being published. No need to repeat his comment.
Your email will never be revealed.

Search terms


  • generate public key
  • linux public key
  • encryption ssh
  • generate ssh key
  • generate ssh keys
  • public key in linux
  • linux public key
  • generate id_rsa
  • linux public key
  • public keys linux
  • referred to public key in linux
  • which is a key and a key is generated
  • how to generate a public key
  • generate ssh key
  • install ssh
  • ssh encryption
  • create public key
  • generate public key
  • install ssh centos
  • public keys linux
  • create rsa key linux
  • generate public key linux
  • key generate rsa
  • generate keys in linux
  • generate public keys
  • generate rsa
  • generate rsa linux
  • suse install openssh
  • ensure ssh
  • how to create ssh keys on debian
  • ssh RSA key setup in ubuntu
  • where I add the public key? ubuntu-es
  • encryption of emails in centos
  • ssh key generation
  • id_rsa generate pub
  • generate public key linux
  • public key generate rsa
  • generate ssh key
  • generate ssh keys
  • install ssh keys
  • which is a public key in linux
  • centos ssh
  • What is a key and a key is generated?
  • add ssh keys
  • add public key
  • ensure ssh linux
  • Solaris 10 ssh keys
  • how to find a public key in linux
  • how to generate public keys
  • how to make a public key in ubuntu 9 10
  • how to make a public key
  • how to make a public key in suse
  • how to install ssh on Linux 9 10
  • client configuration dns ubuntu 9 10
  • configurar 2 RSA public key
  • configure file authorized_keys
  • create keys in linux
  • create keys linux
  • ssh encrypt
  • generate authorized_keys