0

I made an alias to make it easier to connect to my AWS EC2 instance. Although there is an error. Here is the code in ~/.bash_profile:

alias aws_connect=‘ssh -i /path/to/keyfile.pem  ec2-user@xx.xxx.xxx.xxx’

When I type "aws_connect in the terminal, this is what comes out: -bash: “ssh: command not found. This is the output when I type source ~/.bash_profile:

MacBook-Pro:~ username$ source ~/.bash_profile
-bash: alias: -i: not found
-bash: alias: /path/to/keyfile.pem: not found
-bash: alias: ec2-user@xx.xxx.xxx.xxx”: not found

Can anyone see what I did wrong?

2
  • 1
    Is that a cut and paste? If so, the quote marks are wrong - they should be ' not ‘’ – Paul Aug 19 '14 at 5:59
  • That worked. OS X automatically makes ' into ‘’. – Isserlis Aug 19 '14 at 18:20
1

Why not using ssh config for this?

You can achieve this by creating a config file in your ~/.ssh folder:

vim ~/.ssh/config and then add something like this:

Host example HostName Server_IP_or_hostname User SSH_USER IdentityFile ~/path/to_your_key

And then when you want to ssh all you have to do is type:

ssh example

<2cents>

2
  • Ah, I didn't know this was possible. I'm new to OS X. Thanks. – Isserlis Aug 23 '14 at 0:52
  • No problem. This works in both OSX and Linux and is really helpful when you have quite few servers to connect on :-) – mariusv Aug 23 '14 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.