Since SFTP stands for SSH + FTP, I assume I always should create a SSH key pair for it, however, I see in my client configuration that that is optional.
That is applicable for both server-side and client-side SSH key pair.
A host key is mandatory for any ssh server. The server can have multiple host keys using different algorithms. If no key is present when the server is started a host key is generated for the server.
An ssh client can authenticate with a wide range of different methods. The two most common are
publickey. As the name suggests only
publickey requires a key. It is very often recommended to use
publickey as it has multiple security benefits compared to
publickey is also better for the user experience.
The above applies both when using
ssh to run commands on the remote machine as well as when using
sftp to transfer files. Once your keys have been created the same key files will be used for all three commands.