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!

ssh Article's
30 articles in total
Favicon
How to Set Up Key-Based and Password-Based SSH for a Newly Created User on an EC2 Instance
Favicon
SSH Keys | Change the label of the public key
Favicon
่ฎฉๅฎ‰ๅ“ๆ‰‹ๆœบไธๅ†ๅƒ็ฐ๏ผšๅœจๅฎ‰ๅ“ๆ‰‹ๆœบไธŠๆญๅปบ Rust ๅผ€ๅ‘็Žฏๅขƒ
Favicon
SSH port forwarding from within code
Favicon
Mastering Ansible on macOS A Step by Step Guide
Favicon
kkTerminal โ€”โ€” A terminal for Web SSH connection
Favicon
Set Up SSH in 1 Minute Setup Like a Pro (With Some Fun Along the Way)
Favicon
How to Configure GitHub Authentication Using SSH Certificates
Favicon
Understanding SSH: Secure Shell Protocol
Favicon
Check gitlab ssh key auth
Favicon
How I Secured Port 22
Favicon
SSH port forwarding from within Raku code
Favicon
Changing an established SSH connection without disconnecting
Favicon
SSH port forwarding from within Rust code
Favicon
Configure SSH Passwordless Login from Windows to Linux
Favicon
Push to multiple GitHub accounts!
Favicon
Access to Google Cloud Virtual Machine through SSH
Favicon
Large file transfer from VPS to local machine
Favicon
Secure Your Ubuntu VPS: Restrict SSH Access to a Specific IP
Favicon
Accessing Remote Databases Without VPN Using SSH Tunnels
Favicon
Carla Simulator 1 : How to Set Up CARLA Simulator ๐ŸŽ๏ธ๐Ÿ”ฅ
Favicon
Getting Started with Oysape: Exploring Task and Pipeline
Favicon
Increase Debian based Linux VPS serverโ€™s security
Favicon
Splunk - SSH Dashboard Creation
Favicon
Debugging SSH connections: A Comprehensive Guide
Favicon
Understanding SSH Key Pairs: A Developer's Guide
Favicon
SSH Config File - Forgotten Gem
Favicon
SSH kalitini Github.com'ga qo'shish
Favicon
Using SSH to Connect Local Git to Remote Repositories
Favicon
Quickly and Easily Manage Multiple SSH and GPG Keys Across Git Repositories

Featured ones: