Sure, good idea!
Executing R from RStudio terminal
> system("ssh-keygen -f id_rsa -t rsa -N ''")
Generating public/private rsa key pair.
Saving key "id_rsa" failed: Permission denied
Executing the same R binary from SSH
> system("ssh-keygen -f id_rsa -t rsa -N ''")
Generating public/private rsa key pair.
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
...