SSH into your AWS instance?

http://wiki.fast.ai/index.php/Github says to “SSH into your AWS instance”. How does one do that?

ssh -i ~/.ssh/aws-key-fast-ai.pem ubuntu@$instanceUrl

Thanks. I pasted that into Terminal, and this is what it said:

“Warning: Identity file /Users/mhutson/.ssh/aws-key-fast-ai.pem not accessible: No such file or directory.
ssh: connect to host port 22: Connection refused”

Am I doing something wrong?

Did you download your AWS key to that file location? It might be called something else, or you might not have saved it.

Have you gone through the AWS setup lesson? You should have set up your ssh credentials for your aws instance in that lesson

http://course.fast.ai/lessons/aws.html

After you’ve done that you can also get aws-alias.sh from the github repo and use that to ssh into your instance

I have a /Users/mhutson/.ssh/aws-key.pem …
I just tried typing “ssh -i ~/.ssh/aws-key.pem ubuntu@$instanceUrl” and it says:
“ssh: connect to host port 22: Connection refused”

So someone from the original class had the same error:

The answer was just to make sure you’re instance is running (might even take a minute or two for ssh to be up and running):

1 Like

Hi - Have you checked that $instanceUrl is populated? can you try:

echo $instanceUrl

It should give you your instance’s ip address. You can go to the EC2 console and confirm that it is correct.

Hello,
I’m facing a similar issue here, unable to connect to the p2 instance through ssh. I’ve made sure the instance is running, went through the forum for possible solutions, ensured ip address is same, tried terminating and starting properly a quite a few times (released all resources as mentioned n wiki). I’ve been through aws troubleshooting pages to make sure the inbound rules, route table etc are ok. I’m using the scripts from git (https://github.com/fastai/courses/tree/master/setup). able to start and stop instance (using aws-alias.sh)from bash, but cant ping/ssh!! any suggestion that would possibly lead to a fix would be great help. could it be some issue with my laptop (Windows 7)? can’t connect to the instance via browser as well.



Edit : tried the below using aws-alias.sh. tried with a t2 xlarge instance as restarts are cheaper.

Have you tried:

a.) using the ip address instead

b.) tried with firewalls turned off?

c.) try: https://www.infobyip.com/sshservertest.php to see if it’s the instance or your computer

UPDATE: I just tried to ssh to your 54.x.x.x instance and it works for me. Definitely a firewall issue.

Hi Sid,
figured out that my ISP (BSNL India) has blocked port 22 access to servers, hence the issue. tested that I’m able to ssh using a different ISP.
oh! and, I’d terminated my t2 xlarge with the ip 54.148.232.69. so when you managed to ssh, it was probably with someone else. Thanks for the help :slight_smile:
Any idea if we could ssh using a different port? if port 22 is the only way to go, I might have to consider switching my ISP and the process takes at least more than a week I believe.

You definitely can but you’ll need another connection (maybe using your cell phone data? or friend’s internet) to do the following:

  1. edit /etc/ssh/sshd_config
  2. Uncomment “Port 22” and change it to “Port 443”
  3. restart the service with service ssh restart

Good luck.

You can also try using docker-machine - makes it very easy to start up and connect to new AWS instances.

Restart the instance fixed this issues

Here’s a good guide on getting a Jupyter Notebook running on AWS and SSHing to it. Found it helpful when other port confusion issue fixes weren’t working.