156 votes
Accepted

What significance does the user/host at the end of an SSH public key file hold?

This field is a comment, and can be changed or ignored at will. It is set to user@host by default by ssh-keygen. The OpenSSH sshd(8) man page describes the format of a public key thus: Public keys ...
Michael Hampton's user avatar
97 votes
Accepted

How to get a .pem file from ssh key pair?

According to this, this command can be used: ssh-keygen -f id_rsa -e -m pem This will convert your public key to an OpenSSL compatible format. Your private key is already in PEM format and can be ...
fuero's user avatar
  • 9,551
58 votes

What significance does the user/host at the end of an SSH public key file hold?

This is briefly explained in manual page for sshd(8) in section about authorized keys: Protocol 2 public key consist of: options, keytype, base64-encoded key, comment. In openssh context of ...
Jakuje's user avatar
  • 9,545
54 votes

How to get a .pem file from ssh key pair?

Using ssh-keygen to export the key in the .pem format worked for me. ssh-keygen -f id_rsa.pub -m 'PEM' -e > id_rsa.pub.pem Then simply copy the .pem key as necessary. Options as follows: (See man ...
Matt's user avatar
  • 2,751
19 votes

What significance does the user/host at the end of an SSH public key file hold?

As others have pointed out, it's a comment to allow you to identify which key is which. When looking at a single key in eg id_rsa.pub it doesn't make a great deal of difference but when looking at a ...
Håkan Lindqvist's user avatar
18 votes

How to get a .pem file from ssh key pair?

Initially, when using ssh-keygen, I could generate a public key that was compatible with AWS EC2, but had issues with creating private keys that were compatible. The following creates both public and ...
Mike Barlow - BarDev's user avatar
16 votes

Turn off strict checking of ssh keys

The problem is that ssh presumes a 1-to-1 mapping between IP addresses and hosts. We need to break that mapping only for the IP addresses of your cloud servers. The Solution Add the following stanza ...
hackerb9's user avatar
  • 261
13 votes
Accepted

How to verify the private key I have matches AWS keypair?

There are two methods, depending on how you created your SSH key as described in Verifying Your Key Pair's Fingerprint in AWS docs. Here is my SSH key fingerprint in the console: And here is how to ...
MLu's user avatar
  • 24.5k
11 votes

How to get all fingerprints for .ssh/authorized_keys(2) file

A one-liner based on the /dev/stdin trick from ℝaphink's answer and man xargs → EXAMPLES: egrep '^[^#]' ~/.ssh/authorized_keys | xargs -n1 -I% bash -c 'ssh-keygen -l -f /dev/stdin <<<"%"...
akavel's user avatar
  • 357
9 votes

Straight forward way to run ssh-agent and ssh-add on login via SSH?

Another alternative is to add this to your .bashrc. This has the same advantage as Erik's answer (ensuring a single instance) but doesn't require an additional package. # SSH Agent should be running, ...
womblerone's user avatar
8 votes

Straight forward way to run ssh-agent and ssh-add on login via SSH?

One alternative is to use Funtoo's Keychain. Then you can stick this one-liner in your bash shell: eval $(keychain --eval id_rsa) That does the same thing (launches ssh agent, etc.), while also not ...
Erik Aronesty's user avatar
8 votes

Getting SHA1 Digest of SSH Public Key

UPDATE: this answer is about OpenSSH fingerprints. Per comment from the OP the actual problem was apparently AWS fingerprints, which at the time I didn't know are different; for that see Why does my ...
dave_thompson_085's user avatar
8 votes

Ubuntu 20.04 ssh-keygen unknown option -G unable to generate Diffie-Hellman parameters

The reason invoked was to free up several option letters for the ssh-keygen command. This was consolidated in additional -O options and an modified use of the -M option, which breaks compatibility ...
A.B's user avatar
  • 10.4k
6 votes
Accepted

Several ed25519 keys with the same prefix

This is perfectly normal. The SSH key type is encoded in BASE64 encoding at the beginning of the public key and is necessarily always the same for the same key type. echo 'AAAAC3NzaC1lZDI1NTE5AAAA' |...
Sven's user avatar
  • 98.3k
5 votes

What significance does the user/host at the end of an SSH public key file hold?

Very, very simple: Me and you are humans using a machine. So looking at this example you posted: ssh-rsa [piles of gobbledygook]…CA9gyE8HRhNMG6ZDwyhPBbDfX root@mydomain A machine can read this: ssh-...
Giacomo1968's user avatar
  • 3,532
5 votes
Accepted

Changing the ssh passphrase on a private key has no effect

ssh-agent is storing encrypted key in memory so change to the physical key on disk does not affect its functionality. If you want make sure the change is effective, remove the key from agent and add ...
Jakuje's user avatar
  • 9,545
5 votes
Accepted

Deleted authorized_keys from EC2 but still have PPK file and I'm connected

Ok, this is really easy: Open puttygen Click Load and Load PPK file Copy the key that is on the first textarea (public key for pasting...) In the linux server create ~/.ssh/authorized_keys and paste ...
AlfaTeK's user avatar
  • 275
5 votes

Reconnect automatically to a disconnected ssh session

AutoSSH is the tool you want to use for this. It starts the SSH connection and restarts it in case it breaks up.
Tero Kilkanen's user avatar
5 votes
Accepted

SSH asks for password even after i copied the public key to the remote machines

You are not being asked for the password for the remote host. You are being asked for the passphrase for the ssh key you created. To fix the problem, supply the passphrase. If you did not want a ...
Michael Hampton's user avatar
4 votes

SSH by key incredibly slow

Do you have the same troubles by password authentication, or this is really related to key authentication? You client may provide proper DNS resolution, but it is your server which will try anyway to ...
philippe's user avatar
  • 2,263
3 votes

users to connect SFTP server with openssh key

Users should generally connect using their own keys. I assume you are referring to connecting from the command line, and SFTP uses the SSH protocol. So if the users have ssh-copy-id installed, they ...
rubynorails's user avatar
3 votes

How to get all fingerprints for .ssh/authorized_keys(2) file

ssh-keygen -l -f - <authorized_keys produces a nice listing for you: # ssh-keygen -l -f - <authorized_keys 2048 SHA256:GzZ7.................................RqTEag foo (RSA) 2048 SHA256:/y0.........
Jon Bundesen's user avatar
3 votes

How to setup ssh for a couple of servers?

On your workstation: Start the ssh-agent on your workstation if it is not running already. Check with ssh-add -L ; the error message Could not open a connection to your authentication agent. means ...
HBruijn's user avatar
  • 75k
3 votes

What can someone do with your SSH Private Key?

Being able to produce the private key corresponding to a public one is what identifies you to a system. An SSH private key can and should be protected by a good passphrase. Crassly, the strength of ...
Mikael H's user avatar
  • 5,001
3 votes

Adding a ssh host key for a server name to `known_hosts` idempotently?

You can use ssh-keygen to check if the known_hosts file contains entries for a specific host, like this: lacek@Teloth:~$ ssh-keygen -f ~/.ssh/known_hosts -F 192.168.153.254 # Host 192.168.153.254 ...
Lacek's user avatar
  • 7,143
3 votes

how to generate a small RSA key

There is no way in standard ssh-keygen to do this. But you can download source code from https://github.com/openssh/openssh-portable and recompile it with SSH_RSA_MINIMUM_MODULUS_SIZE set to 512 bits ...
Navern's user avatar
  • 1,609
2 votes

How do you manage ssh keys to add a second user?

You'll need to append the contents of Joe's public key (.ssh/id_rsa.pub) to the ~newuser/.ssh/authorized_keys file on the server. I would reccomend using RDP on the macbook to connect to your windows ...
smokes2345's user avatar
2 votes

How do I change my private key passphrase?

If you don't have ssh-keygen installed, you can also use openssl directly key="/path/to/your.key" algo="-des3" # or -aes256 or ... openssl rsa $algo -in "$key" -out &...
mivk's user avatar
  • 3,821
2 votes

How to verify the private key I have matches AWS keypair?

Historically, ssh-keygen displayed fingerprints using a hex-encoded MD5 hash. More recently, OpenSSH added support for -- and changed the default to -- base64-encoded SHA-256. You can add the option "...
Matt Nordhoff's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible