
The easiest way to issue commands on an Amazon EC2 Linux instance is to connect to it using a terminal/command line over the SSH protocol. Secure Shell (SSH) is a cryptographic network protocol that can be used to securely connect to a computer operating system over an unsecured network. What’s SSH and how is it used with Amazon EC2 instances? NOTE: SSH agent forwarding should be enabled with caution as allowing SSH agent forwarding creates a security risk as anyone with root access on the remote host can directly access your local SSH agent through the socket and use the keys by impersonating you on other machines on the network. This is depicted in the image below (note that the SSH keys only exist on the client computer): This means you can connect from your computer where your SSH public key file is located and authenticate straight through to the instance in the private subnet via the bastion host in the public subnet. The SSH Agent forwarding feature allows a local SSH agent to reach through an existing SSH connection and authenticate on a remote server. The SSH agent keeps private keys safe and saves you from typing a passphrase each time while you connect to a server.

The SSH-agent is a key manager for SSH, which holds keys and certificates in memory. This method allows you to securely connect to Linux instances in private Amazon VPC subnets via a bastion host (aka jump host) that is located in a public subnet.

You can SSH into EC2 instances in a private subnet using SSH agent forwarding. You might be running Amazon EC2 instances in public and private subnets and need a way to SSH into the EC2 instances in the private subnet.
