Select your language

Automatic authentication on OpenSSH servers using public key cryptography and PuTTY

A convenient way to resolve remote access to servers can be to authenticate using cryptographic keys. This option is convenient, but perhaps not recommended to manage remote access by SSH to servers exposed to traffic. Automatic authentication is preferable in controlled environments, test environments without sensitive data or simply, environments without potential attackers close :)
In a test environment, having to constantly enter user and key can become tiresome. The most convenient thing is to use public key cryptography to automate authentication. Regarding clients, we will exemplify for PuTTY, since it is probably the most widespread Windows client for SSH. The steps to follow are as follows:

Step 1

Using the PuTTY key generator, which is called PuTTY Key Generator (PuTTYgen), we create a pair of keys using, for example, SSH-2 RSA-2048. It is important not to use SSH-1 keys, as they are exploitable. 1024 is an acceptable length in controlled environments, although it also costs nothing to generate keys of 2048 bits in length.

IMPORTANT: The PuTTY key format is not the native OpenSSH key format, so the key we are interested in is the converted one, which appears in the box "Public key for pasting into OpenSSH authorized_keys file". If we use the non-converted public key on the SSH server, authentication will not work. In 99.9% of cases, a message "Server refused our key" when logging in is because we have used in authorized_keys the native Key of PuTTY and not the converted key, which we remember, appears in the box "Public key for pasting into OpenSSH authorized_keys file".

- Publicidad -

NOT LEAST: In order to reuse the keys, you have to save them. In addition, as we will see in the next step, PuTTY needs to have access to the generated private key, so it is imperative to save it. We can do without passphrase for the private key, so the authentication process will be transparent and we will not be asked about the protection passphrase. In a real environment, you have to protect the private key always. Needless to say, the final security of our platform will depend on the proper conservation of the keys (especially the private one, the public one can be distributed).

Step 2

The next thing is to incorporate the public keys of the users to whom we want to provide autologin in the file of authorized keys of our SSH server. This file where the authorized keys are located is usually called authorized_keys, and it is normal to find these files in the .ssh directories of the different home of the users.

We paste there our public key (in native OpenSSH format, I will not tire of saying it) created with PuTTYgen.

Step 3

In the PuTTY client, we go to "Connection --> data", and write the user with whom we want to autologin. In "connection --> SSH --> Key", we specify the private key that we have generated with PuTTYgen. We go back to the main screen, "Session" and save that configuration.

Step 4

- Publicidad -

We restart the SSH daemon (FreeBSD /etc/rc.d/sshd restart, consult Google for other systems). From now on, we will automatically authenticate against SSH, without having to use a key and password.

Using username "root".
Authenticating with public key "user-root"
Last login: Sat Oct 6 15:09:05 2007 from 192.168.1.3
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.

FreeBSD 6.2-RELEASE-p4 (SMP) #0: Thu Apr 26 17:55:55 UTC 2007

Welcome to FreeBSD!

$

NOTES

- Publicidad -

NOTE: For regular users, who are not the root, we will create, logged in like that user, the .ssh folder and provide it with read permissions for only that user:

$ mkdir /home/shernando/.ssh
$ chmod -R og= /home/shernando/.ssh

Inside that folder we will place the file authorized_keys with the user's public key.

NOTE 2: It is important that the SSH daemon supports authentication based on a public key, so in the configuration file (/etc/ssh/sshd_config in FreeBSD, see Google for other platforms) you have to have the following fields in "yes":

RSAAuthentication yes
PubkeyAuthentication yes

Source: SergioHernando

See original.

No comments

• If you're already registered, please log in first. Your email will not be published.

Comments are closed

The comments for this content are closed.

Security becomes a technological platform

Security becomes a technological platform

Mexico. Security is moving from a set of standalone systems to an integrated technology platform that combines artificial intelligence, video analytics, sensors, access control, and data platforms....

Security industry in Mexico and Latin America continues its expansion and professionalization

Security industry in Mexico and Latin America continues its expansion and professionalization

International. The security industry in Mexico and Latin America maintains a growth trend driven by digital transformation, the increase in physical and cyber risks, as well as the need to protect...

Veeam Introduces Agent Commander to Address AI Agent Risks in Enterprise Environments

Veeam Introduces Agent Commander to Address AI Agent Risks in Enterprise Environments

United States. Veeam Software today announced the launch of Agent Commander, a solution aimed at helping organizations detect risks associated with artificial intelligence, protect AI-based systems...

Key and asset management, the key to optimizing operations in logistics, distribution and construction companies

Key and asset management, the key to optimizing operations in logistics, distribution and construction companies

In industries where every minute counts, efficient asset and resource management has become a strategic factor to ensure operational continuity, safety, and productivity. By: Héctor Meléndez,...

Genesis Security Reduces False Alarms by 62% Through Milestone Integration and Actuate AI Analytics

Genesis Security Reduces False Alarms by 62% Through Milestone Integration and Actuate AI Analytics

Puerto Rico. A centralized monitoring operation developed by Genesis Security was able to significantly reduce the volume of false alarms in its security systems, thanks to the integration of...

Case study: Solar cameras and thermal intelligence optimize the safety of aquaculture farms

Case study: Solar cameras and thermal intelligence optimize the safety of aquaculture farms

Türkiye. An open-ocean fish farming farm in Turkey implemented a smart surveillance system based on Dahua solar cameras, thermal monitoring, and wireless data transmission to improve safety and...

 The Hidden Security Gap in Data Centers

The Hidden Security Gap in Data Centers

Imagine the journey of an authorized technician inside a data center. When he arrives, he presents his credential and enters the premises, and before entering the server corridor he needs a key to...

Digital fraud increased at Christmas

Digital fraud increased at Christmas

Colombia. During the holiday season, as e-commerce and digital transactions intensified, online fraud attempts also increased. Fake promotions, impersonation of businesses and messages that...

Milestone XPerience Days arrived in Mexico City with innovations in intelligent video management

Milestone XPerience Days arrived in Mexico City with innovations in intelligent video management

Mexico. Milestone Systems, a leading provider of open platform video management software (VMS), hosted the Milestone XPerience Days Mexico 2025 event, a gathering that brought together industry...

Hikvision Mexico launches the third edition of

Hikvision Mexico launches the third edition of "Hikvision Women"

Mexico. Hikvision Mexico announced the launch of the third edition of its "Hikvision Women" program, an initiative aimed at strengthening the participation and professional development of women in...

Suscribase Gratis
Remember Me
SUBSCRIBE TO OUR ENGLISH NEWSLETTER
DO YOU NEED A SERVICE OR PRODUCT QUOTE?
LATEST INTERVIEWS
SITE SPONSORS










LATEST NEWSLETTER
Latest Newsletter