Logo

dev-resources.site

for different kinds of informations.

SSH Keys | Change the label of the public key

Published at
1/13/2025
Categories
devops
ssh
sre
linux
Author
nuwan_arambage
Categories
4 categories in total
devops
open
ssh
open
sre
open
linux
open
Author
14 person written this
nuwan_arambage
open
SSH Keys | Change the label of the public key

Hope everyone is in the journey of year 2025. Today, let's talk something which is trivial and usually comes across when you work in DevOps or SRE space. It is about ssh public key.

I have seen many cases that ssh public key label is rarely used to specifically identify perticular public key. Most of the time the keys are generated keeping the default label whcih has the user@hostname format. General usecase is engieer generates the public and private key for automation or authentication and turns the blind eye for -C option which creates lable for public key.

Essentially, it is pretty simple. We can generate the ssh key using label or we can edit manually after ssh keys are generated. Let's learn by doing . Simply generate a ssh key by following command.

ssh-keygen -t rsa -b 4096 -f ./id_rsa

Following is the execution output when above command is run. I would not go to explain more in -t, -b and -f options. man pages could give you details.

[root@jenkin-slave-node .wyoc]# ssh-keygen  -t rsa -b 4096 -f ./id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./id_rsa.
Your public key has been saved in ./id_rsa.pub.
The key fingerprint is:
SHA256:cDEkDXCL9/I79yVUQ11cm0uuhiwKZLrrWLiPwbedUTY [email protected]
The key's randomart image is:
+---[RSA 4096]----+
|    ..+++     .o=|
|     o o.o   .  =|
|    . + .     o+ |
|     . +     .o..|
|     o.ES   .  o |
|. . + oo. ... .  |
| + + o  .. o.o.  |
|  B + + o.o .o   |
| +o*.o ..o ..    |
+----[SHA256]-----+
Enter fullscreen mode Exit fullscreen mode

The result of this command is following files. One is a private key other one is a public key.

[root@jenkin-slave-node .wyoc]# ls -l id*
-rw------- 1 root root 3243 Jan 13 08:32 id_rsa  <-- private key
-rw-r----- 1 root root  760 Jan 13 08:32 id_rsa.pub <-- public key
[root@jenkin-slave-node .wyoc]#
Enter fullscreen mode Exit fullscreen mode

Let's open the public key using cat command and see the output. Scroll to the right and find string --> [email protected] .
Well, that is the one we called the comment or label which we found after the ssh public key.

[root@jenkin-slave-node .wyoc]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCv+QOF1jiZ8C5//btEQkhsDbaG00Ftce9tbsFj2WxnEZPEnWmkG+jMDKAxp3IuXzn1H+NP0uT0whcumClCwrpwH7NFcWigxPbcQhMaIWcYovqmDqY1liCDNoCAjmgQBbypIJXGNkHzeuVOoYhfKah3ZuXNnMv3y6m+KXuLdxko1lUdYmZHYfDTNi0Ho6WeW3tVZ48pvsUsOGrrc7fn5z923CH750oOem/i4Of6cL2qIoSd4Jrfs9T/aUNHGN5G5qw08I/Zkm3J/LiWi+0C7zJFdnVWueHkBIshpqD+7vwWF7/zMzGwidr0YVATc8LEHuKfmwOjmkQFT5VkzKRCxlE711NvtXmqPqF0E603OXTs5QfAznMuFb6y6N71E6b9PM8wZeG5SXgAIMv8kr1xnsBQ2NU5EZu1TfFaO+A3lHBw4YjO0hhqZeDz9QwC02iVBS4lJJjKvYlSlmwPfuR9NZ70f9tefsSG0zEo1K2UiGoHCOacyrR3Bo+rKdiYre6Gam9rZyC7Uksl1b64KtNqkesYCUMG9CtGsTMySbljVv3AuJI/6LG7dAIjnbPTDIaW+CbWyW2yqVAAvHlx19j/Hjc6HYv5ikHhYZm6EZ7bN3C4vnLs+LOdUAi03sc2ETr5ECLN0YMduGfh7IHYcxkxEsUvXZy96OibNdiQef/7md/Lkw== [email protected]_
Enter fullscreen mode Exit fullscreen mode

I would like to add my perspective on labeling ssh public key. Because it gives more clarity and maintainability. So I have mentioned below important notes.

Important Notes

  1. You can edit the label manually after ssh public key is generated. This can be done via vim command.

  2. Or You can use the ssh key gen command with -C option. For example following command is helpful.

[root@jenkin-slave-node .wyoc]# ssh-keygen -t rsa -b 4096 -f ./id_rsa-a -C "JenkinMasterNodePublicKey"

In conclusion, I hope this is a helpful tip and happy reading who spend time to come here. If you have a different perspective, let's make a comment.

Take care till we meet again with a new post. Cheers!

linux Article's
30 articles in total
Favicon
Easy development environments with Nix and Nix flakes!
Favicon
Setting Up a Simple Two-Node Kubernetes Cluster in No Time
Favicon
Nextcloud on Raspberry Pi - Fedora + Podman Quadlets
Favicon
NVIDIA Drivers with Secure Boot on Ubuntu
Favicon
Как создать свой VPN и получить доступ ко всему?
Favicon
How I used a named pipe to save memory and prevent crashes (in Perl)
Favicon
KDE vs GNOME vs Others: Choosing the Best Linux Desktop Environment in 2025
Favicon
The Linux Foundation Data and AI Fundamentals
Favicon
Kubernetes Security Best Practices
Favicon
A new shell for using modern alternatives to Unix commands
Favicon
Como configurar 2FA em Servidores Linux
Favicon
Configurar servidor de archivos local con Ubuntu y Samba
Favicon
Google Cloud Shell: Establishing Secure Connections via SSH
Favicon
Understanding Linux Shells: Interactive, Non-Interactive, and RC Files
Favicon
[Boost]
Favicon
I am going to learn java in next 8 weeks, please follow me for regular updates
Favicon
Configuring network access with Cisco ASA via minicom utility
Favicon
Fixing Linux Backup Sync Issues for exFAT Compatibility
Favicon
Enhance Your macOS Terminal with Oh My Zsh, Autosuggestions, and Powerlevel10k
Favicon
Turning Markdown into Learning: publishing a challenge on labs.iximiuz.com
Favicon
Fixes for a critical rsync vulnerability (CVE-2024-12084) have been released for Stable/Bookworm, Testing and Unstable....
Favicon
My Zig with Ghostty
Favicon
Understanding Node Problem Detector in Kubernetes: Beyond Default Node Conditions
Favicon
Nginx Simplified: Technical Insights with Real-World Analogies
Favicon
GNOME vs KDE Plasma: Which One Is for You?
Favicon
SSH Keys | Change the label of the public key
Favicon
Debian and KDE 6 - WSL - How to install KDE 6 via Debian - Windows 11 - X410 - Linux - 2024 https://www.youtube.com/watch?v=yrtgmwsptVc
Favicon
Linux/Unix login overview and a bit of clever tricks with "history"
Favicon
🏆 Branching to Level Up in the Cloud! ☁️
Favicon
Mastering Linux File Systems: Everything You Need to Know About Symlinks and Hard Links

Featured ones: