- Install the cloud SDK
- There are instructions here.
- I use OS X and Homebrew so I just ran the following instead.
brew tap caskroom/cask
brew cask install google-cloud-sdk
- Then run the following commands to setup and log in.
gcloud init
gcloud auth list
- List the versions available
- Run this to list all the releases available You can delete the last grep to see betas and release candidates as well.
gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images | grep -i freebsd- | grep -release
- Now to create a new instance
- Update the following command as needed and run it.
gcloud compute instances create "InstanceName" --machine-type "g1-small" --network "default" --subnet "default" --maintenance-policy "MIGRATE" --image "freebsd-11-1-release-amd64" --image-project=freebsd-org-cloud-dev --boot-disk-size "30" --boot-disk-type "pd-standard"
InstanceName
should be changed to a useful host name.--machine-type
can just be g1-small for now, or another option from tis list.gcloud compute machine-types list
gcloud compute machine-types lis
t--network
and--subnet
will probably need to be changed to your custom network. You can list the available options with these commands.gcloud compute networks list
gcloud compute networks subnets list
--image
can be changed another version from the earlier list.--boot-disk-size
should be at least 30GB. You can add additional drives later.--boot-disk-type
can bepd-standard
orpd-ssd
depending if you want SSD or not.- This should create and power on the VM and you will now be able to see it in the website and make adjustments to the configuration as needed.
- To gain SSH access to this server you will need to do the following steps.
- Ensure you can ping the servers internal or external IP address.
- Optionally go into the Google Cloud -> VPC network -> Firewall rules and add a rule for
tcp:22
traffic route to the network or server. - Create a public key and load it onto the server. This step is required and was one of my major hurdles.
- Check that you have a public key on the computer to authenticate
cat ~/.ssh/id_rsa.pub
- If you don't have this file its empty runt he following to create one.
ssh-keygen -t rsa -f ~/.ssh/id_rsa
- Add this public key to the instances you can access it.
gcloud compute instances add-metadata InstanceName --metadata-from-file sshKeys=~/.ssh/id_rsa.pub
- Or you can add it to the entire project.
gcloud compute project-info add-metadata --metadata-from-file sshKeys=~/.ssh/id_rsa.pub
- Now you will be able to login with the following.
gcloud compute ssh freebsd-recovery
If you get errors like
Operation timed out
they would indicate issues with your networking, firewall rules, or ip address configuration. If you get a Permission denied (publickey)
error instead it means the public key was not loaded properly form the ~/.ssh/id_rsa
file. You can also open the file in a text editor and manually enter it in the VM instance under Custom metadata with a key of sshKeys
.Note that this authentication is per device, but once you authenticate you can enable password login the ssh config and add other users if you want.
1 comment:
Nice post !NEET Coaching Classes
Post a Comment