The SSH connection is not implemented by RStudio or R but by the ssh client you have installed in your system. You haven't gave us any information about your system but I'm guessing you are on Windows and using Git Bash as your terminal for RStudio? If that is the case then you need to make sure to have the SSH client installed and use the Command Prompt as your terminal, install WSL to use Bash or use Putty as your SSH client outside of RStudio.
Have in mind that configuring communications with an EC2 instance in AWS is outside of this forum's scope, regardless of what software you are running on the virtual server.