Connect to AWS ParallelCluster with EC2 Instance Connect

Posted on Feb 11, 2022
tl;dr: SSH/SCP into cluster without a keypair

Connect to AWS ParallelCluster with EC2 Instance Connect

EC2 Instance connect allows you to SSH into an EC2 instance without a keypair. You can also perform basic file transfer i.e. SFTP and SCP with it.


  • doesn’t require an SSH keypair
  • connects to private IP addresses (you still need network connectivity)

You can read more about it here.

  1. First install the ec2instanceconnectcli helper:
pip install ec2instanceconnectcli
  1. Connect to the instance with the mssh command:
export AWS_DEFAULT_REGION='us-east-2'
mssh $(pcluster describe-cluster --cluster-name hpc6a | jq -r '.headNode.instanceId')

The above command can be shortened using a bash alias:

# usage: pssh [cluster-name]
pssh() {
    mssh $(pcluster describe-cluster --cluster-name ${1} | jq -r '.headNode.instanceId')

And then simply run as:

pssh hpc6a

Transfer Files

You can transfer a file, for example to the cluster via:

tar -cf - | mssh i-0117826db1caefe88 --region us-east-2 tar -xvf -

This can be set as an alias:

# usage: pscp [cluster-name] [filepath]
pscp() {
    tar -cf - ${2} | mssh $(pcluster describe-cluster --cluster-name ${1} | jq -r '.headNode.instanceId') tar -xvf -

and run like:

pscp hpc6a