Friday, June 28, 2013

Setting up ssh config

Unwieldy SSH Execution

# -- Executed on local machine
# Login to AWS as the ubuntu user using your private key pair
$ cd downloads # or wherever your pem file is
$ ssh -i skey.pem ubuntu@ec2-54-218-73-84.us-west-2.compute.amazonaws.com


# Login to AWS as ubuntu using your private key pair and run uptime command
$ ssh -i skey.pem ubuntu@ec2-54-218-73-84.us-west-2.compute.amazonaws.com uptime


Setting up ~/.ssh/config

# -- Execute on local machine
$ mkdir -p ~/.ssh
$ cp ~/downloads/skey.pem ~/.ssh/
$ chmod 400 ~/.ssh/skey.pem
$ chmod 700 ~/.ssh
$ nano ~/.ssh/config # edit the file as shown below
$ cat ~/.ssh/config

Host awshost1
    HostName ec2-54-218-35-71.us-west-2.compute.amazonaws.com

    User ubuntu
    IdentityFile "~/.ssh/skey.pem"



Rapid SSH Execution

# -- Execute on local machine
# SSH using the ’awshost1’ alias defined in ~/.ssh/config
$ ssh awshost1
# SSH using an alias, run a command, and then exit
$ ssh awshost1 uptime

No comments:

Post a Comment