Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do configure Coda to work for my Amazon EC2 instance?

I can not connect to my EC2 instane. I have opened port 21 in the AWS Console. I think there is no way of input my SSH Key pair in Coda. Is there a way of connecting Coda to my EC2 instance?

like image 338
einstein Avatar asked Jun 03 '11 08:06

einstein


People also ask

How do you attach a key pair to an instance?

To add or replace a key pairConnect to your instance using your existing private key. Using a text editor of your choice, open the . ssh/authorized_keys file on the instance. Paste the public key information from your new key pair underneath the existing public key information.

Can I change key pair for EC2 instance?

Once an instance has been started, there is no way to change the keypair associated with the instance at a meta data level, but you can change what ssh key you use to connect to the instance.

How can the EC2 instance be configured?

Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . Choose Launch Instance. In Step 1: Choose an Amazon Machine Image (AMI), find an Amazon Linux 2 AMI at the top of the list and choose Select. In Step 2: Choose an Instance Type, choose Next: Configure Instance Details.


1 Answers

Coda should pick up settings from your ssh config so you can configure this fairly easily.

If you've saved your EC2 ssh keypair in ~/.ssh/ec2_rsa then simply edit ~/.ssh/config to look like:

IdentityFile ~/.ssh/ec2_rsa

You can also restrict the IdentityFile directive to just your AWS resource with:

Host somehost.amazonaws.com
    IdentityFile ~/.ssh/ec2_rsa

If everything's configured properly then you should be able to, from the command line, run ssh username@awshost and get a login prompt

If you continue to have problems you can always enable password authentication on your instance by editing /etc/ssh/sshd_config and adding the line PasswordAuthentication yes to the end of the file, then setting a password for your user with passwd

I use the following settings in my .ssh/config to automatically apply my EC2 keypairs for EC2 resources:

# EC2 Northern Virginia
Host *.compute-1.amazonaws.com
    IdentityFile ~/.keys/ssh/ec2/us_east_1.key
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentitiesOnly yes
    ForwardAgent no

# EC2 Northern California:
Host *.us-west-1.compute.amazonaws.com
    IdentityFile ~/.keys/ssh/ec2/us_west_1.key
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentitiesOnly yes
    ForwardAgent no

# EC2 Ireland:
Host *.eu-west-1.compute.amazonaws.com
    IdentityFile ~/.keys/ssh/ec2/eu_west_1.key
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentitiesOnly yes
    ForwardAgent no

# EC2 Singapore:
Host *.ap-southeast-1.compute.amazonaws.com
    IdentityFile ~/.keys/ssh/ec2/ap_southeast_1.key
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentitiesOnly yes
    ForwardAgent no

# EC2 Tokyo:
Host *.ap-northeast-1.compute.amazonaws.com
    IdentityFile ~/.keys/ssh/ec2/ap_northeast_1.key
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentitiesOnly yes
    ForwardAgent no
like image 121
Peter Avatar answered Sep 19 '22 21:09

Peter