How do I add an SSH key to a google compute cloud VPS instance?Why is ssh-add adding duplicate identity keys?Trying to do ssh authentication with key files: server refused our keyerror: environment has no access-key or secret-keyRestore SSH Key from txtssh key login to vps woesMAAS/VirtualBox Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed and SSH failsStill being Prompt for Password After enabling Public KeysPublic key authentication Permission denied (publickey)Key based SSH login that requires both key AND passwordSSH without password only works one time

Why would a jet engine that runs at temps excess of 2000°C burn when it crashes?

Can infringement of a trademark be pursued for using a company's name in a sentence?

Making a sword in the stone, in a medieval world without magic

What happens with multiple copies of Humility and Glorious Anthem on the battlefield?

Plywood subfloor won't screw down in a trailer home

Need some help with my first LaTeX drawing…

Can the druid cantrip Thorn Whip really defeat a water weird this easily?

Good allowance savings plan?

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

What exactly is the purpose of connection links straped between the rocket and the launch pad

Force user to remove USB token

What Happens when Passenger Refuses to Fly Boeing 737 Max?

Why must traveling waves have the same amplitude to form a standing wave?

How does Dispel Magic work against Stoneskin?

Word for a person who has no opinion about whether god exists

Coworker uses her breast-pump everywhere in the office

Rejected in 4th interview round citing insufficient years of experience

How to deal with a cynical class?

Extension of Splitting Fields over An Arbitrary Field

"One can do his homework in the library"

What is the definition of "Natural Selection"?

Is all copper pipe pretty much the same?

Is it true that real estate prices mainly go up?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?



How do I add an SSH key to a google compute cloud VPS instance?


Why is ssh-add adding duplicate identity keys?Trying to do ssh authentication with key files: server refused our keyerror: environment has no access-key or secret-keyRestore SSH Key from txtssh key login to vps woesMAAS/VirtualBox Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed and SSH failsStill being Prompt for Password After enabling Public KeysPublic key authentication Permission denied (publickey)Key based SSH login that requires both key AND passwordSSH without password only works one time













1















How do I add an SSH key to a cloud instance?



I tried adding keys manually, but just couldn't connect.
Here's what I tried:



thufir@mordor:~$ 
thufir@mordor:~$ gcloud compute config-ssh
WARNING: The private SSH key file for Google Compute Engine does not exist.
WARNING: You do not have an SSH key for Google Compute Engine.
WARNING: [/usr/bin/ssh-keygen] will be executed to generate a key.
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/thufir/.ssh/google_compute_engine.
Your public key has been saved in /home/thufir/.ssh/google_compute_engine.pub.
The key fingerprint is:
SHA256:ioreurewiopruweoiprwe thufir@mordor
The key's randomart image is:
+---[RSA 2048]----+
.......
| |
| |
+----[SHA256]-----+

Updated [https://www.googleapis.com/compute/v1/projects/<project>].
You should now be able to use ssh/scp with your instances.
For example, try running:

$ ssh <instance>.<location>.<project>

thufir@mordor:~$
thufir@mordor:~$ ssh <instance>.<location>.<project>
The authenticity of host 'compute.<####> (<ip address>)' can't be established.
ECDSA key fingerprint is SHA256:<fingerprint?>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'compute.<####>' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.



The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

$
$
$ whoami
thufir
$ pwd
/home/thufir
$ exit
Connection to <ip address> closed.
thufir@mordor:~$









share|improve this question




























    1















    How do I add an SSH key to a cloud instance?



    I tried adding keys manually, but just couldn't connect.
    Here's what I tried:



    thufir@mordor:~$ 
    thufir@mordor:~$ gcloud compute config-ssh
    WARNING: The private SSH key file for Google Compute Engine does not exist.
    WARNING: You do not have an SSH key for Google Compute Engine.
    WARNING: [/usr/bin/ssh-keygen] will be executed to generate a key.
    Generating public/private rsa key pair.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/thufir/.ssh/google_compute_engine.
    Your public key has been saved in /home/thufir/.ssh/google_compute_engine.pub.
    The key fingerprint is:
    SHA256:ioreurewiopruweoiprwe thufir@mordor
    The key's randomart image is:
    +---[RSA 2048]----+
    .......
    | |
    | |
    +----[SHA256]-----+

    Updated [https://www.googleapis.com/compute/v1/projects/<project>].
    You should now be able to use ssh/scp with your instances.
    For example, try running:

    $ ssh <instance>.<location>.<project>

    thufir@mordor:~$
    thufir@mordor:~$ ssh <instance>.<location>.<project>
    The authenticity of host 'compute.<####> (<ip address>)' can't be established.
    ECDSA key fingerprint is SHA256:<fingerprint?>.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'compute.<####>' (ECDSA) to the list of known hosts.
    Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)

    * Documentation: https://help.ubuntu.com
    * Management: https://landscape.canonical.com
    * Support: https://ubuntu.com/advantage

    Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

    0 packages can be updated.
    0 updates are security updates.



    The programs included with the Ubuntu system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.

    Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
    applicable law.

    $
    $
    $ whoami
    thufir
    $ pwd
    /home/thufir
    $ exit
    Connection to <ip address> closed.
    thufir@mordor:~$









    share|improve this question


























      1












      1








      1








      How do I add an SSH key to a cloud instance?



      I tried adding keys manually, but just couldn't connect.
      Here's what I tried:



      thufir@mordor:~$ 
      thufir@mordor:~$ gcloud compute config-ssh
      WARNING: The private SSH key file for Google Compute Engine does not exist.
      WARNING: You do not have an SSH key for Google Compute Engine.
      WARNING: [/usr/bin/ssh-keygen] will be executed to generate a key.
      Generating public/private rsa key pair.
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in /home/thufir/.ssh/google_compute_engine.
      Your public key has been saved in /home/thufir/.ssh/google_compute_engine.pub.
      The key fingerprint is:
      SHA256:ioreurewiopruweoiprwe thufir@mordor
      The key's randomart image is:
      +---[RSA 2048]----+
      .......
      | |
      | |
      +----[SHA256]-----+

      Updated [https://www.googleapis.com/compute/v1/projects/<project>].
      You should now be able to use ssh/scp with your instances.
      For example, try running:

      $ ssh <instance>.<location>.<project>

      thufir@mordor:~$
      thufir@mordor:~$ ssh <instance>.<location>.<project>
      The authenticity of host 'compute.<####> (<ip address>)' can't be established.
      ECDSA key fingerprint is SHA256:<fingerprint?>.
      Are you sure you want to continue connecting (yes/no)? yes
      Warning: Permanently added 'compute.<####>' (ECDSA) to the list of known hosts.
      Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)

      * Documentation: https://help.ubuntu.com
      * Management: https://landscape.canonical.com
      * Support: https://ubuntu.com/advantage

      Get cloud support with Ubuntu Advantage Cloud Guest:
      http://www.ubuntu.com/business/services/cloud

      0 packages can be updated.
      0 updates are security updates.



      The programs included with the Ubuntu system are free software;
      the exact distribution terms for each program are described in the
      individual files in /usr/share/doc/*/copyright.

      Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
      applicable law.

      $
      $
      $ whoami
      thufir
      $ pwd
      /home/thufir
      $ exit
      Connection to <ip address> closed.
      thufir@mordor:~$









      share|improve this question
















      How do I add an SSH key to a cloud instance?



      I tried adding keys manually, but just couldn't connect.
      Here's what I tried:



      thufir@mordor:~$ 
      thufir@mordor:~$ gcloud compute config-ssh
      WARNING: The private SSH key file for Google Compute Engine does not exist.
      WARNING: You do not have an SSH key for Google Compute Engine.
      WARNING: [/usr/bin/ssh-keygen] will be executed to generate a key.
      Generating public/private rsa key pair.
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in /home/thufir/.ssh/google_compute_engine.
      Your public key has been saved in /home/thufir/.ssh/google_compute_engine.pub.
      The key fingerprint is:
      SHA256:ioreurewiopruweoiprwe thufir@mordor
      The key's randomart image is:
      +---[RSA 2048]----+
      .......
      | |
      | |
      +----[SHA256]-----+

      Updated [https://www.googleapis.com/compute/v1/projects/<project>].
      You should now be able to use ssh/scp with your instances.
      For example, try running:

      $ ssh <instance>.<location>.<project>

      thufir@mordor:~$
      thufir@mordor:~$ ssh <instance>.<location>.<project>
      The authenticity of host 'compute.<####> (<ip address>)' can't be established.
      ECDSA key fingerprint is SHA256:<fingerprint?>.
      Are you sure you want to continue connecting (yes/no)? yes
      Warning: Permanently added 'compute.<####>' (ECDSA) to the list of known hosts.
      Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)

      * Documentation: https://help.ubuntu.com
      * Management: https://landscape.canonical.com
      * Support: https://ubuntu.com/advantage

      Get cloud support with Ubuntu Advantage Cloud Guest:
      http://www.ubuntu.com/business/services/cloud

      0 packages can be updated.
      0 updates are security updates.



      The programs included with the Ubuntu system are free software;
      the exact distribution terms for each program are described in the
      individual files in /usr/share/doc/*/copyright.

      Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
      applicable law.

      $
      $
      $ whoami
      thufir
      $ pwd
      /home/thufir
      $ exit
      Connection to <ip address> closed.
      thufir@mordor:~$






      server ssh cloud google vps






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 28 '16 at 11:23







      Thufir

















      asked Jul 28 '16 at 8:36









      ThufirThufir

      1,610944101




      1,610944101




















          2 Answers
          2






          active

          oldest

          votes


















          3














          Probably a too late answer, but here it is



          ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C <service-account>


          Then



          gcloud compute ssh <service-account> --command="bash xxxxxx"





          share|improve this answer























          • What is the command "bash xxxxxx"?

            – ian-campbell
            May 18 '17 at 4:24






          • 1





            This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

            – alschytt
            May 19 '17 at 6:02


















          0














          You don't need to add it in user folder manually. Google Cloud will add it automatically every time you try to log in to your VM.
          To permanently add SSH Key in a VM instance you can add your public key in metadata in the menu. Step wise step process is explained here.





          share






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f803908%2fhow-do-i-add-an-ssh-key-to-a-google-compute-cloud-vps-instance%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            Probably a too late answer, but here it is



            ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C <service-account>


            Then



            gcloud compute ssh <service-account> --command="bash xxxxxx"





            share|improve this answer























            • What is the command "bash xxxxxx"?

              – ian-campbell
              May 18 '17 at 4:24






            • 1





              This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

              – alschytt
              May 19 '17 at 6:02















            3














            Probably a too late answer, but here it is



            ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C <service-account>


            Then



            gcloud compute ssh <service-account> --command="bash xxxxxx"





            share|improve this answer























            • What is the command "bash xxxxxx"?

              – ian-campbell
              May 18 '17 at 4:24






            • 1





              This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

              – alschytt
              May 19 '17 at 6:02













            3












            3








            3







            Probably a too late answer, but here it is



            ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C <service-account>


            Then



            gcloud compute ssh <service-account> --command="bash xxxxxx"





            share|improve this answer













            Probably a too late answer, but here it is



            ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C <service-account>


            Then



            gcloud compute ssh <service-account> --command="bash xxxxxx"






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 19 '17 at 11:56









            alschyttalschytt

            312




            312












            • What is the command "bash xxxxxx"?

              – ian-campbell
              May 18 '17 at 4:24






            • 1





              This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

              – alschytt
              May 19 '17 at 6:02

















            • What is the command "bash xxxxxx"?

              – ian-campbell
              May 18 '17 at 4:24






            • 1





              This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

              – alschytt
              May 19 '17 at 6:02
















            What is the command "bash xxxxxx"?

            – ian-campbell
            May 18 '17 at 4:24





            What is the command "bash xxxxxx"?

            – ian-campbell
            May 18 '17 at 4:24




            1




            1





            This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

            – alschytt
            May 19 '17 at 6:02





            This is how I use it : after generating a key I run a deployment script on the remote instance - so in my case it's "bash deploy.sh".

            – alschytt
            May 19 '17 at 6:02













            0














            You don't need to add it in user folder manually. Google Cloud will add it automatically every time you try to log in to your VM.
            To permanently add SSH Key in a VM instance you can add your public key in metadata in the menu. Step wise step process is explained here.





            share



























              0














              You don't need to add it in user folder manually. Google Cloud will add it automatically every time you try to log in to your VM.
              To permanently add SSH Key in a VM instance you can add your public key in metadata in the menu. Step wise step process is explained here.





              share

























                0












                0








                0







                You don't need to add it in user folder manually. Google Cloud will add it automatically every time you try to log in to your VM.
                To permanently add SSH Key in a VM instance you can add your public key in metadata in the menu. Step wise step process is explained here.





                share













                You don't need to add it in user folder manually. Google Cloud will add it automatically every time you try to log in to your VM.
                To permanently add SSH Key in a VM instance you can add your public key in metadata in the menu. Step wise step process is explained here.






                share











                share


                share










                answered 2 mins ago









                Vipin YadavVipin Yadav

                95




                95



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f803908%2fhow-do-i-add-an-ssh-key-to-a-google-compute-cloud-vps-instance%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Möglingen Índice Localización Historia Demografía Referencias Enlaces externos Menú de navegación48°53′18″N 9°07′45″E / 48.888333333333, 9.129166666666748°53′18″N 9°07′45″E / 48.888333333333, 9.1291666666667Sitio web oficial Mapa de Möglingen«Gemeinden in Deutschland nach Fläche, Bevölkerung und Postleitzahl am 30.09.2016»Möglingen

                    Virtualbox - Configuration error: Querying “UUID” failed (VERR_CFGM_VALUE_NOT_FOUND)“VERR_SUPLIB_WORLD_WRITABLE” error when trying to installing OS in virtualboxVirtual Box Kernel errorFailed to open a seesion for the virtual machineFailed to open a session for the virtual machineUbuntu 14.04 LTS Virtualbox errorcan't use VM VirtualBoxusing virtualboxI can't run Linux-64 Bit on VirtualBoxUnable to insert the virtual optical disk (VBoxguestaddition) in virtual machine for ubuntu server in win 10VirtuaBox in Ubuntu 18.04 Issues with Win10.ISO Installation

                    Antonio De Lisio Carrera Referencias Menú de navegación«Caracas: evolución relacional multipleja»«Cuando los gobiernos subestiman a las localidades: L a Iniciativa para la Integración de la Infraestructura Regional Suramericana (IIRSA) en la frontera Colombo-Venezolana»«Maestría en Planificación Integral del Ambiente»«La Metrópoli Caraqueña: Expansión Simplificadora o Articulación Diversificante»«La Metrópoli Caraqueña: Expansión Simplificadora o Articulación Diversificante»«Conózcanos»«Caracas: evolución relacional multipleja»«La Metrópoli Caraqueña: Expansión Simplificadora o Articulación Diversificante»