https://www.techrepublic.com/article/how-to-view-your-ssh-keys-in-linux-macos-and-windows/
How to view your SSH public key on Linux
There are two easy ways to view your SSH public key in Linux. The first method is a bit complicated, because it makes use of both ssh-agent and ssh-add commands. This is probably overkill for what you need, but it's a good way to view the key, while requiring your SSH keypair password. The command is:
ssh-agent sh -c 'ssh-add; ssh-add -L'
Upon successful authentication, your SSH public key will print out in the terminal. You can then copy that and paste it where you need. Of course, that's a lot of commands to remember, especially when you just need to view the contents of the public key.
If you don't want to have to memorize yet another command, you could simply use the cat command like so:
cat ~/.ssh/id_rsa.pub
The above command will print out your SSH key on your Linux machine, without prompting you for your key authentication password.
How to view your SSH public key on macOS
Viewing your keys on macOS can be done in similar fashion as Linux. Open your terminal window and issue the command:
cat ~/.ssh/id_rsa.pub
Or:
cat /Users/USERNAME/.ssh/id_rsa.pub
Where USERNAME is your macOS username.
The above commands will print out your SSH public key.
macOS also has one more nifty trick up its sleeve. You can copy the contents of the SSH key directly to the clipboard, without displaying the key, using the pbcopy tool. This command would be:
cat ~/.ssh/id_rsa.pub | pbcopy
Once you've copied the key to your clipboard, you can paste it wherever you need it.
How to view your SSH public key on Windows
On Windows, you'll use the type command to view your SSH public key like so:
type C:\Users\USERNAME\.ssh\id_rsa.pub
Where USERNAME is the name of your user.
The above command will display your SSH public key. You can then use the Ctrl+c keyboard shortcut to copy the contents of the file.
You can also do something similar to what we did on macOS (copying the SSH public key directly to the clipboard) using the type and clip commands like so:
type C:\Users\USERNAME\.ssh\id_rsa.pub | clip
Where USERNAME is your username.
You can now paste that key wherever you need it.
No comments:
Post a Comment