The key format has not changed. The only thing that changes is the signature format that's sent during each authentication handshake.
What makes everything confusing is that originally in SSHv2, the key type and the signature type used to be defined in combination. (For example, the same "ssh-rsa" identifier was defined to mean RSA keys and RSA/SHA-1 signatures.) So changing the signature process would have meant assigning a new key type identifier, and that would have meant generating a new key...
However, protocol extensions have been developed to avoid this, and modern SSH clients will automatically negotiate the signature types whenever RSA keys are involved. If you connect with
ssh -v you will notice a few additional packets being exchanged:
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,
So you can continue using "ssh-rsa" keys – you only need to upgrade the software on both ends to something reasonably recent, and it will automatically start producing "rsa-sha2-256" signatures from that key. (For example, you might need to install a new version of PuTTY and Pageant, and you might have troubles with older versions of gpg-agent.)
Signatures in ssh-keygen
the default option
rsa for the
-t argument explains that the chosen option is using the SHA1 signature, so one should choose
rsa-sha2-256 for example.
This applies when issuing certificates, but is irrelevant when generating plain keys.
Each certificate is signed by the parent CA at the time it is issued. This long-term signature is stored in the certificate itself (and it's very important to realize that this is a different thing from the short-term signatures that are made during each connection and then thrown away). That's why many HTTPS (X.509) certificates had to be replaced – the issuing CA had stamped them with RSA/SHA-1 signatures.
OpenSSH has also created its own certificate format, which is what the manual page is referring to. These so-called "SSH certificates" are not just regular SSH keys – they're additionaly signed by e.g. your workplace CA. So if you have files whose names end with
*-cert.pub, you might need to have those re-issued. (Use
ssh-keygen -Lf <file> to check how they were signed).
But plain SSH keys do not hold any long-term signature inside – they're only used to make temporary signatures during each connection. So there is nothing that needs replacement in the key itself.
I tried checking the type of the key with
ssh-keygen -l -f key and it shows me that it is indeed SHA256 type
No, that is not what ssh-keygen shows at all. The
-l option is showing you the key's "fingerprint" and it's telling you that it used SHA256 to compute this fingerprint – but it has nothing to do with the key's type, nor with how the key will actually be used. The fingerprint is just a hash that was computed right now in order to be shown to you.
(Remember that previously SSH software used to show MD5-based key fingerprints – even though there was no MD5 usage in the actual SSHv2 protocol.)
Other key types
Is this the type not recommended anymore and I should switch for example, to ECDSA?
From what I know (i.e. from what I gathered on Security.SE), RSA as a signature algorithm is still strong – problems mostly just occur when trying to use RSA as an encryption algorithm, and that's not an issue with SSHv2. (Well, the ever-increasing key size is not great either.)
ECDSA has its own problems – it is difficult to get its implementation right and certain kinds of programmer mistakes can be disastrous. If you had to switch, EdDSA (that is ssh-ed25519 or ssh-ed448) would be a better option.