{"id":638,"date":"2021-07-18T12:57:32","date_gmt":"2021-07-18T07:27:32","guid":{"rendered":"https:\/\/askadmin.com\/?p=638"},"modified":"2021-07-24T16:18:40","modified_gmt":"2021-07-24T10:48:40","slug":"the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx","status":"publish","type":"post","link":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/","title":{"rendered":"The Easy way to manage Google cloud Instances from Mac OSx"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>Do you find it difficult to connect to your google cloud VM via SSH using ssh keys\u00a0 and\u00a0 you have to login to google cloud console frequently to start\u00a0 and stop your VM instances ?.<\/p>\n<p><a href=\"https:\/\/cloud.google.com\/sdk\">Google Cloud SDK<\/a> productive tools come in handy not only to manage APIs and websites deployment but also to manage Google Cloud servers.<\/p>\n<p>Many of us\u00a0 connect to google vm instances using several methods like connecting through a\u00a0 browser and access cloud instance directly from google console\u00a0 or connect to it using a SSH client\u00a0 with password authentication ( not secure and not recommended)\u00a0 and connect using\u00a0 generated and uploaded SSH keys to google console.\u00a0 But to take control of complete cloud instance management\u00a0 such as creating a cloud instance or starting a cloud instance etc., ,\u00a0 \u00a0one needs to login to google console or use google-cloud-sdk APIs.<\/p>\n<p>&nbsp;<\/p>\n<p>Generating SSH keys and connecting to\u00a0 cloud servers\u00a0 using default MacOsX terminal\u00a0 may not be that convenient.\u00a0 \u00a0I use <a href=\"https:\/\/iterm2.com\/\">iTerm2<\/a> in conjunction with\u00a0 google-cloud-sdk on my mac\u00a0 to manage google cloud services.\u00a0 Google-cloud-sdk can be installed on a mac OsX\u00a0 by downloading the package from google directly or with home brew command line utility .<\/p>\n<p>&nbsp;<\/p>\n<p>Now let us see step by step procedure to install and configure google-cloud-sdk to manage cloud instances .<\/p>\n<h6>1.Install Home Brew package manager for mac osx<\/h6>\n<p>Installing <a href=\"https:\/\/brew.sh\/\">homebrew<\/a> is a straightforward process. It is as easy as just copy&amp;paste a single line command in MacOsx terminal .<\/p>\n<p><em><strong>\/bin\/bash -c &#8220;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&#8221;<\/strong><\/em><\/p>\n<p>&nbsp;<\/p>\n<h6>2.Install GoogleCloud SDK using brew<\/h6>\n<p>The next step\u00a0 is installing google-cloud-sdk .\u00a0 Google-cloud-sdk can be installed by directly <a href=\"https:\/\/cloud.google.com\/sdk\">downloading the package from google<\/a> or with homebrew . I installed it using homebrew as I have already brew installed on my macosx .<\/p>\n<p class=\"p1\"><em><strong><span class=\"s1\">brew install &#8211;cask google-cloud-sdk<\/span><\/strong><\/em><\/p>\n<p><em><strong>gcloud\u00a0init\u00a0<\/strong><\/em><\/p>\n<p><strong><em>gcloud init<\/em><\/strong>\u00a0 initiates\u00a0 google-cloud-sdk\u00a0 environment\u00a0 on mac OSX . If you encounter<\/p>\n<p>gcloud <span class=\"s1\">: command not found error then you may have to copy below line in your <em>~\/.bash_profile\u00a0 to let your mac OSX\u00a0 know\u00a0 the executable path . <\/em><\/span>If you do not see\u00a0 .bash_profile in your home directory . You can create one and paste the line.<\/p>\n<p><strong>vi ~\/.bash_profile<\/strong><\/p>\n<p><em><strong><span class=\"s1\">export PATH=\/usr\/local\/Caskroom\/google-cloud-sdk\/latest\/google-cloud-sdk\/bin:$PATH<\/span><\/strong><\/em><\/p>\n<p>&nbsp;<\/p>\n<p>It may prompt for your google cloud login credentials for once .<\/p>\n<p>&nbsp;<\/p>\n<h6>3.Install and use iTerm SSH Terminal (optional)<\/h6>\n<p>Now we can connect to google cloud instances from your favourite terminal ( I use <a href=\"https:\/\/iterm2.com\/\">iTerm2<\/a>) .<\/p>\n<p>Let us see some of the\u00a0 commands\u00a0 to manage google cloud instance .<\/p>\n<p>&nbsp;<\/p>\n<h6>Useful Google Cloud Commands To manage VM instances<\/h6>\n<p>To connect to a cloud instance using ssh , enter below command .<\/p>\n<p><strong>gcloud compute ssh<\/strong> <em>YourInstanceName<\/em><\/p>\n<p>Start a VM instance\u00a0 with this command.<\/p>\n<p><strong>gcloud compute instances start<\/strong> <em>YourInstanceName<\/em><\/p>\n<p>you can start multiple instances at once .<\/p>\n<p><em><strong>gcloud compute instances start\u00a0<\/strong>YourInstanceName1 YourInstanceName2\u00a0<\/em><\/p>\n<p>and to stop google cloud instances use the following command .<\/p>\n<p><em><strong>gcloud compute instances stop <\/strong><\/em>YourInstanceName1 YourInstanceName2<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Do you find it difficult to connect to your google cloud VM via SSH using ssh keys\u00a0 and\u00a0 you have to login to google cloud console frequently to start\u00a0 and stop your VM instances ?. Google Cloud SDK productive tools come in handy not only to manage APIs and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1,7,10,9],"tags":[205,207,209,204,208,206],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Easy way to manage Google cloud Instances from Mac OSx - Ask Admin - A Lifelong Learner<\/title>\n<meta name=\"description\" content=\"Using google cloud sdk saves lot of time by avoiding you login to google cloud console or to connect to ssh\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Easy way to manage Google cloud Instances from Mac OSx - Ask Admin - A Lifelong Learner\" \/>\n<meta property=\"og:description\" content=\"Using google cloud sdk saves lot of time by avoiding you login to google cloud console or to connect to ssh\" \/>\n<meta property=\"og:url\" content=\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/\" \/>\n<meta property=\"og:site_name\" content=\"Ask Admin - A Lifelong Learner\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-18T07:27:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-24T10:48:40+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"balu sreekanth\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/askadmin.com\/aa\/#website\",\"url\":\"https:\/\/askadmin.com\/aa\/\",\"name\":\"Ask Admin - A Lifelong Learner\",\"description\":\"Mobile App Development | IP Telephony | Linux\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/askadmin.com\/aa\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/#webpage\",\"url\":\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/\",\"name\":\"The Easy way to manage Google cloud Instances from Mac OSx - Ask Admin - A Lifelong Learner\",\"isPartOf\":{\"@id\":\"https:\/\/askadmin.com\/aa\/#website\"},\"datePublished\":\"2021-07-18T07:27:32+00:00\",\"dateModified\":\"2021-07-24T10:48:40+00:00\",\"author\":{\"@id\":\"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345\"},\"description\":\"Using google cloud sdk saves lot of time by avoiding you login to google cloud console or to connect to ssh\",\"breadcrumb\":{\"@id\":\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/askadmin.com\/aa\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Easy way to manage Google cloud Instances from Mac OSx\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345\",\"name\":\"balu sreekanth\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/askadmin.com\/aa\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g\",\"caption\":\"balu sreekanth\"},\"sameAs\":[\"http:\/\/askadmin.com\"],\"url\":\"https:\/\/askadmin.com\/aa\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Easy way to manage Google cloud Instances from Mac OSx - Ask Admin - A Lifelong Learner","description":"Using google cloud sdk saves lot of time by avoiding you login to google cloud console or to connect to ssh","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/","og_locale":"en_US","og_type":"article","og_title":"The Easy way to manage Google cloud Instances from Mac OSx - Ask Admin - A Lifelong Learner","og_description":"Using google cloud sdk saves lot of time by avoiding you login to google cloud console or to connect to ssh","og_url":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/","og_site_name":"Ask Admin - A Lifelong Learner","article_published_time":"2021-07-18T07:27:32+00:00","article_modified_time":"2021-07-24T10:48:40+00:00","twitter_misc":{"Written by":"balu sreekanth","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/askadmin.com\/aa\/#website","url":"https:\/\/askadmin.com\/aa\/","name":"Ask Admin - A Lifelong Learner","description":"Mobile App Development | IP Telephony | Linux","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/askadmin.com\/aa\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/#webpage","url":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/","name":"The Easy way to manage Google cloud Instances from Mac OSx - Ask Admin - A Lifelong Learner","isPartOf":{"@id":"https:\/\/askadmin.com\/aa\/#website"},"datePublished":"2021-07-18T07:27:32+00:00","dateModified":"2021-07-24T10:48:40+00:00","author":{"@id":"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345"},"description":"Using google cloud sdk saves lot of time by avoiding you login to google cloud console or to connect to ssh","breadcrumb":{"@id":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/askadmin.com\/aa\/the-easy-way-to-manage-google-cloud-instances-with-ssh-from-mac-osx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/askadmin.com\/aa\/"},{"@type":"ListItem","position":2,"name":"The Easy way to manage Google cloud Instances from Mac OSx"}]},{"@type":"Person","@id":"https:\/\/askadmin.com\/aa\/#\/schema\/person\/e1ff95d4a91ea001e25af3273533a345","name":"balu sreekanth","image":{"@type":"ImageObject","@id":"https:\/\/askadmin.com\/aa\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6aebf95935573dc70f536f1003a2fb8c?s=96&d=mm&r=g","caption":"balu sreekanth"},"sameAs":["http:\/\/askadmin.com"],"url":"https:\/\/askadmin.com\/aa\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts\/638"}],"collection":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/comments?post=638"}],"version-history":[{"count":13,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts\/638\/revisions"}],"predecessor-version":[{"id":653,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/posts\/638\/revisions\/653"}],"wp:attachment":[{"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/media?parent=638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/categories?post=638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/askadmin.com\/aa\/wp-json\/wp\/v2\/tags?post=638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}