SSH-ing to Google Compute Engine instance through Mac OS X terminal - macos

I have created an instance on Google Compute Engine, but I can't seem to SSH using the terminal. The command that I used was :
gcloud compute ssh example-instance
The error that I got was:
ERROR: (gcloud.compute.ssh) Could not SSH to the instance. It is possible that your SSH key has not propagated to the instance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic.
When I googled the error, I was led to this link:Unable to SSH to Google Cloud
I went and checked the firewall rules here https://cloud.google.com/compute/docs/troubleshooting#ssherrors and things seem fine. I also went onto ~/.ssh and checked for google_compute_engine and google_compute_engine.pub which indicate the presence of my private and public key. I was wondering what I should do next? Is this is a problem specific to Mac workstations?
Any help would be really appreciated.

Personally, had some trouble getting my ssh keys setup correctly by following the Google Cloud Engine docs. Found another logical solution...
This didn't take long and solved the problem (i.e., simple ssh access to Google Cloud VM via MacOS Terminal)...
Follow these simple instructions provided by nixCraft:
https://www.cyberciti.biz/faq/google-cloud-compute-engin-ssh-into-an-instance-from-linux-unix-appleosx/

Here are a few other things to check:
Can you ssh into that instance from a browser, using the "SSH" button in the Cloud Console?
If not, try a newly created instance using default settings and compare how your example-instance differs.
Run gcloud config list and confirm that the values for project, account, region, and zone match your expectations.

Related

EC2 instance putty re-used keypair not recognised

First up it's nearly impossible to identify if this is a duplicate or not given the generic nature of the displayed error. This is potentially a very specific and niche scenario. Please do not falsely mark this as duplicate. It's sad that I have to type this :(
I have 2 ec2 ubuntu instances. The first one created 6 months ago and working perfectly.
I created a second ubuntu instance this morning and told it to use the same keypair as the existing instance. They're in the same zones(?) but different base vpc. I selected it from the list so I presume it should be visible to both vpc's. From what I could see that should be ok.
Both are ubuntu so the user is "ubuntu". Both are using the same key pair. I merely cloned my saved putty config and changed the public IP before attempting to connect however i'm getting the "PuTTY Fatal Error: Disconnected: No supported authentication methods available (server sent: publickey) OK: error.
Unless i'm mistaken the same .ppk should work for both instances, that's the entire purpose of keypairs. The only thing I can presume is that AWS failed to associate the key pair with the new instance.
What are the likely reasons for this happening?
AWS documentation https://aws.amazon.com/premiumsupport/knowledge-center/linux-credentials-error/
Says to check the username "ubuntu" and key pair name which are both correct.
I'm going to blow the instance away and start again but it would be nice to be able to know what AWS is doing wrong so I can avoid the issue in the future.
Update: New instance... I imported a different pub key and used that and the problem persists when I try and connect with it's associated ppk.
The issue was the AWS Amazon Machine Image (AMI) I was using. I was using the latest ubuntu??. When I switched to the other ubuntu it worked fine.

Aws git access/curl issue

I am having something strange using AWS subnet with ubuntu instances.
I have create the public/private subnet schema with one ubuntu instance on the private one. Everything is working smoothly, I can git clone, curl...
However when creating any other ubuntu instance on the private subnet within the same VPC, I can't use git at all, even a simple curl to https://gitlab.com is not working (getting no answer).
I tried an other url like google and got a successful result.
Do you have an idea why I am getting this behaviour and specially only for gitlab?
Appreciate your help

Viewing Docker Compose web app on server outside host machine (the host is OSX)

My computer is OSX. I'm logged into an ssh connection (Ubuntu), and from there I'm ssh'ed into an OpenStack instance of Ubuntu 14.04. From this OpenStack instance I've been following a Docker-Compose tutorial from the Docker docs : https://docs.docker.com/compose/gettingstarted/
I'm on Step 4, and I'm successfully running a server that is running on http://0.0.0.0:5000/
However, I don't know how to view a GUI Google Chrome browser from my Macbook. Because whenever I go to http://0.0.0.0:5000/ it says server not found, which makes sense because it's not on my computer.
I read something about port forwarding, but I'm not sure that's right here. I'm fairly new, so please help!
Also, is this the right way to use an OpenStack machine? That you use your computer's web browser to view the web app?
I solved it myself. Turns out on OpenStack, you need to create a security group and then add it to your instance. When you create a security group, you can add a port that you want to provide public access to. And then you can view the web app on any computer by typing in your floating IP on OpenStack, colon separated by the public port address.

Unable to connect to SSH server with cloud 9

I've got a digital ocean VPS which I'd like to connect to with Cloud 9's code editor. They have a simple form, which I filled out with the fill out with the required information:
hostname: xxx.xxx.xx.xx
username: stephen
nodejs binary path: /usr/bin/nodejs
Your SSH key: mYpUbLicKey...uploaded through cloud 9's interface
initial path: (optional--I've left blank)
port: (optional--I've left blank)
I get the following error:
Cloud9 couldn't connect to SSH server stephen#xxx.xxx.xx.xx
It's on the default port and allows access to the stephen user (although I tried the above with "root" user and still no dice). Is there something I'm missing here? I tried the exact same commands on the Secure Shell chrome app and I'm able to access the server just fine.
Also I was able to get this to work doing, I believe the exact same thing, but then I realized that I should probably not be doing everything using the root user (I'm a little new at this) so I created the stephen user and changed the information in order to use that user instead. That's when it stopped working. Is it possible that I've given inadvertedly denied access to cloud9 by adding this additional user.
I should also add that I've followed the instructions in cloud9's documentation edited the authorized keys on the server to include the public key that's stored on cloud9.
Any ideas? I know it might be difficult to know what the problem is here, but if someone had an idea at least about where to look, I'd really appreciate it. Thanks.
Could it be that you didn't add the ssh key to ~/.ssh/authorized_keys in the homedir of the stephen user?
Had this same issue even after following the instructions on the documentation. Make sure you're allowing SSH from 0.0.0.0/0 onto port 22 for the EC2 instance.

Amazon AWS EC2 SSH Login Through Putty on Windows

Ok, so I've read the tutorial here:
http://www.powercram.com/2009/07/connecting-to-aws-ec2-instance-linux.html
I created a keypair on Ec2, and ran it through puttygen, and tried to login via putty. I tried logging into the ip of the site, the url of the site, and the public DNS given to me by Amazon. I've tried logging in as root, ec2-user, ubuntu (even though I think its a fedora install, I'm just not sure because I just inherited this project). The name of the keypair on amazon's interface is hooper, so I tried logging in as that. Every time I get "server refused our key". I've read many peoples post on this problem, and none of the solutions seem to work for me. If any one has any other ideas, I'd appreciate it.
Make sure the instance is running under the keypair you think it is - you have to ensure the key PEM file you ran through PuttyGEN is the actual key that the instance is authenticated with.

Resources