That config creates an ssh server, not an ssh configuration for your user. You won’t be able to log into github with that key.
With purely NixOS options, programs.ssh exists, but it would set full-host configuration, which is almost certainly not what you want for an ssh configuration you’re going to be logging into github with.
In either case, you should create a key at runtime and treat it as data; keys are inherently not the type of thing you want to be reproducible, that’s kind of defeating the purpose of a key.
If you want your keys to be associated with a specific device (i.e., one key for every host you use), and you really don’t want to create it by hand, write a systemd user unit that creates the key if it does not exist and make it WantedBy=default.target. For entropy and key consistency’s sake I’d recommend running ssh-keygen by hand, though, you’ll need to manually add any generated keys to your github profile anyway.
i see, i tough that since i can use ssh key to authenticate a host that key should be the one used.
with this i was going to move the key that i normally use to the host key created. better leave at it is them, and have two separated keys for this.
Yes, definitely don’t share your host’s SSH key with your user. It’s good practice to reuse keys as little as reasonable anyway.
You might want to read a bit into how asymmetric key encryption works, and how SSH uses it. It’s a tool people involved with the software world use all the time, having a good understanding of its security model and what it even does is quite important.