0
0
Terraformcloud~10 mins

Connection blocks for SSH in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the SSH user in the connection block.

Terraform
connection {
  type        = "ssh"
  user        = "[1]"
  private_key = file("~/.ssh/id_rsa")
  host        = self.public_ip
}
Drag options to blanks, or click blank then click option'
Aubuntu
Badmin
Croot
Dec2-user
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'root' when the server disables root SSH login.
Using 'admin' which may not exist on the server.
2fill in blank
medium

Complete the code to specify the SSH private key file path in the connection block.

Terraform
connection {
  type        = "ssh"
  user        = "ubuntu"
  private_key = file("[1]")
  host        = self.public_ip
}
Drag options to blanks, or click blank then click option'
A~/.ssh/id_dsa
B~/.ssh/authorized_keys
C~/.ssh/id_rsa
D~/.ssh/config
Attempts:
3 left
💡 Hint
Common Mistakes
Using the public key file instead of the private key.
Using SSH config file instead of key file.
3fill in blank
hard

Fix the error in the connection block by completing the missing host attribute.

Terraform
connection {
  type        = "ssh"
  user        = "ubuntu"
  private_key = file("~/.ssh/id_rsa")
  host        = [1]
}
Drag options to blanks, or click blank then click option'
Aself.public_ip
Bself.private_ip
Cvar.host_ip
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using private IP when connecting from outside the network.
Using localhost which refers to the local machine.
4fill in blank
hard

Fill both blanks to complete the connection block with SSH type and user.

Terraform
connection {
  type = "[1]"
  user = "[2]"
  private_key = file("~/.ssh/id_rsa")
  host = self.public_ip
}
Drag options to blanks, or click blank then click option'
Assh
Bwinrm
Cubuntu
Dec2-user
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'winrm' which is for Windows remote management.
Using 'ec2-user' on non-Amazon Linux instances.
5fill in blank
hard

Fill all three blanks to complete the connection block with SSH type, user, and private key file.

Terraform
connection {
  type        = "[1]"
  user        = "[2]"
  private_key = file("[3]")
  host        = self.public_ip
}
Drag options to blanks, or click blank then click option'
Assh
Bubuntu
C~/.ssh/id_rsa
D~/.ssh/id_dsa
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'winrm' instead of 'ssh'.
Using the wrong private key file path.