SSH without password with non-default identity file location

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
14
down vote

favorite












As part of a startup script I have to automatically open several gnome-terminal windows, one of those terminals automatically send:



ssh user@192.168.1.3


The limitation with this is that I still need to type a password to complete the SSH connection.



What I want to do is for my script to initiate the command and complete the connection. To that extent, I attempted to follow the instructions as outlined in the accepted answer here.



From the system I wish to connect from, I ran:



ssh-keygen
Enter file in which to save the key: /home/user/ssh/keys/server1key


It then prompted me to enter a passphrase. I left this empty, as I wasn't sure what it would be for, so I assumed setting one would require unlocking it with said passphrase each time I'd use it.



Continuing with the instructions linked above, I then ran and received the following:



ssh-copy-id user@IP
ERROR: No identities found


A quick search revealed that I needed to specify the location of the key, as it was not in the default save location, so I fixed that:



ssh-copy-id -i /home/user/ssh/keys/server1key.pub user@192.168.1.3


After asking for the server's password, it successfully added the key. However, upon attempting to log in with "ssh user@IP", I was still prompted for the password.



As far as I'm aware, I followed the linked instructions correctly, so either I'm missing something, or perhaps an existing configuration is preventing me for getting this to work?



Both systems use 18.04 and openssh.







share|improve this question





















  • So I need to specify the location of the .pub file when sending the SSH command?
    – hiigaran
    Aug 7 at 18:18











  • I've got a bit of a different way of organising my files, hence the non-default locations, but you guys have helped greatly. Thanks. Feel free to make it an answer I can accept.
    – hiigaran
    Aug 7 at 18:23














up vote
14
down vote

favorite












As part of a startup script I have to automatically open several gnome-terminal windows, one of those terminals automatically send:



ssh user@192.168.1.3


The limitation with this is that I still need to type a password to complete the SSH connection.



What I want to do is for my script to initiate the command and complete the connection. To that extent, I attempted to follow the instructions as outlined in the accepted answer here.



From the system I wish to connect from, I ran:



ssh-keygen
Enter file in which to save the key: /home/user/ssh/keys/server1key


It then prompted me to enter a passphrase. I left this empty, as I wasn't sure what it would be for, so I assumed setting one would require unlocking it with said passphrase each time I'd use it.



Continuing with the instructions linked above, I then ran and received the following:



ssh-copy-id user@IP
ERROR: No identities found


A quick search revealed that I needed to specify the location of the key, as it was not in the default save location, so I fixed that:



ssh-copy-id -i /home/user/ssh/keys/server1key.pub user@192.168.1.3


After asking for the server's password, it successfully added the key. However, upon attempting to log in with "ssh user@IP", I was still prompted for the password.



As far as I'm aware, I followed the linked instructions correctly, so either I'm missing something, or perhaps an existing configuration is preventing me for getting this to work?



Both systems use 18.04 and openssh.







share|improve this question





















  • So I need to specify the location of the .pub file when sending the SSH command?
    – hiigaran
    Aug 7 at 18:18











  • I've got a bit of a different way of organising my files, hence the non-default locations, but you guys have helped greatly. Thanks. Feel free to make it an answer I can accept.
    – hiigaran
    Aug 7 at 18:23












up vote
14
down vote

favorite









up vote
14
down vote

favorite











As part of a startup script I have to automatically open several gnome-terminal windows, one of those terminals automatically send:



ssh user@192.168.1.3


The limitation with this is that I still need to type a password to complete the SSH connection.



What I want to do is for my script to initiate the command and complete the connection. To that extent, I attempted to follow the instructions as outlined in the accepted answer here.



From the system I wish to connect from, I ran:



ssh-keygen
Enter file in which to save the key: /home/user/ssh/keys/server1key


It then prompted me to enter a passphrase. I left this empty, as I wasn't sure what it would be for, so I assumed setting one would require unlocking it with said passphrase each time I'd use it.



Continuing with the instructions linked above, I then ran and received the following:



ssh-copy-id user@IP
ERROR: No identities found


A quick search revealed that I needed to specify the location of the key, as it was not in the default save location, so I fixed that:



ssh-copy-id -i /home/user/ssh/keys/server1key.pub user@192.168.1.3


After asking for the server's password, it successfully added the key. However, upon attempting to log in with "ssh user@IP", I was still prompted for the password.



As far as I'm aware, I followed the linked instructions correctly, so either I'm missing something, or perhaps an existing configuration is preventing me for getting this to work?



Both systems use 18.04 and openssh.







share|improve this question













As part of a startup script I have to automatically open several gnome-terminal windows, one of those terminals automatically send:



ssh user@192.168.1.3


The limitation with this is that I still need to type a password to complete the SSH connection.



What I want to do is for my script to initiate the command and complete the connection. To that extent, I attempted to follow the instructions as outlined in the accepted answer here.



From the system I wish to connect from, I ran:



ssh-keygen
Enter file in which to save the key: /home/user/ssh/keys/server1key


It then prompted me to enter a passphrase. I left this empty, as I wasn't sure what it would be for, so I assumed setting one would require unlocking it with said passphrase each time I'd use it.



Continuing with the instructions linked above, I then ran and received the following:



ssh-copy-id user@IP
ERROR: No identities found


A quick search revealed that I needed to specify the location of the key, as it was not in the default save location, so I fixed that:



ssh-copy-id -i /home/user/ssh/keys/server1key.pub user@192.168.1.3


After asking for the server's password, it successfully added the key. However, upon attempting to log in with "ssh user@IP", I was still prompted for the password.



As far as I'm aware, I followed the linked instructions correctly, so either I'm missing something, or perhaps an existing configuration is preventing me for getting this to work?



Both systems use 18.04 and openssh.









share|improve this question












share|improve this question




share|improve this question








edited Aug 8 at 3:07









muru

128k19269459




128k19269459









asked Aug 7 at 18:04









hiigaran

747118




747118











  • So I need to specify the location of the .pub file when sending the SSH command?
    – hiigaran
    Aug 7 at 18:18











  • I've got a bit of a different way of organising my files, hence the non-default locations, but you guys have helped greatly. Thanks. Feel free to make it an answer I can accept.
    – hiigaran
    Aug 7 at 18:23
















  • So I need to specify the location of the .pub file when sending the SSH command?
    – hiigaran
    Aug 7 at 18:18











  • I've got a bit of a different way of organising my files, hence the non-default locations, but you guys have helped greatly. Thanks. Feel free to make it an answer I can accept.
    – hiigaran
    Aug 7 at 18:23















So I need to specify the location of the .pub file when sending the SSH command?
– hiigaran
Aug 7 at 18:18





So I need to specify the location of the .pub file when sending the SSH command?
– hiigaran
Aug 7 at 18:18













I've got a bit of a different way of organising my files, hence the non-default locations, but you guys have helped greatly. Thanks. Feel free to make it an answer I can accept.
– hiigaran
Aug 7 at 18:23




I've got a bit of a different way of organising my files, hence the non-default locations, but you guys have helped greatly. Thanks. Feel free to make it an answer I can accept.
– hiigaran
Aug 7 at 18:23










4 Answers
4






active

oldest

votes

















up vote
33
down vote



accepted










It fails for the same reason that ssh-copy-id failed the first time - i.e. because you have chosen a non-default location for the identity file.



You can resolve it in the same way, by adding -i /home/user/ssh/keys/server1key to your ssh command - note that the client side needs the location of the private key file.



From man ssh



 -i identity_file
Selects a file from which the identity (private key) for public
key authentication is read. The default is ~/.ssh/identity for
protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.


Alternatively, you may wish to create a ~/.ssh/config file entry for the host along the lines of



Host somename
Hostname 192.168.1.3
User user
IdentityFile /home/user/ssh/keys/server1key





share|improve this answer



















  • 1




    I always assumed that the config file required indentation - I see that's not the case. Intruiging.
    – Boris the Spider
    Aug 7 at 19:10










  • Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
    – JW0914
    Aug 7 at 23:47










  • @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
    – Sebastian Stark
    Aug 13 at 0:04










  • @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
    – JW0914
    Aug 14 at 0:24

















up vote
2
down vote













Another reason that ssh-copy-id fails, is because the key isn't added to the ssh agent.



First check and start if ssh-agemt is running



$ eval "$(ssh-agent -s)"


If you get in process ID, you can add your key



$ ssh-add -k /home/user/ssh/keys/server1key


With -k you add the key to the keychain



Check if key's are added with



$ ssh-add -l


Ssh-copy-id should working now.






share|improve this answer




























    up vote
    -1
    down vote













    Hope this will work for you.. "sshpass -p yourpassword" it will automatically login to remote host.



    [root@localhost .ssh]# sshpass -p password123 ssh -l root localhost






    share|improve this answer




























      up vote
      -1
      down vote













      Just execute 2 commands:



      ssh-keygen
      ssh-copy-id


      Long answer:



      user@ip:~$ ssh-keygen
      Generating public/private rsa key pair.
      Enter file in which to save the key (/home/user/.ssh/id_rsa): temp_file
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in stemp.
      Your public key has been saved in stemp.pub.
      The key fingerprint is:
      SHA256:5**M user@ip
      The key's randomart image is:
      +---[RSA 2048]----+
      | ... |
      | ... |
      | .. |
      | ..+. o . |
      | |
      | B |
      | |
      |= * |
      |=+ o . |
      +----[SHA256]-----+


      And then:



      user@ip:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub ipDestination -p portDest





      share|improve this answer





















        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',
        convertImagesToLinks: true,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        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%2f1063287%2fssh-without-password-with-non-default-identity-file-location%23new-answer', 'question_page');

        );

        Post as a guest






























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        33
        down vote



        accepted










        It fails for the same reason that ssh-copy-id failed the first time - i.e. because you have chosen a non-default location for the identity file.



        You can resolve it in the same way, by adding -i /home/user/ssh/keys/server1key to your ssh command - note that the client side needs the location of the private key file.



        From man ssh



         -i identity_file
        Selects a file from which the identity (private key) for public
        key authentication is read. The default is ~/.ssh/identity for
        protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
        ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.


        Alternatively, you may wish to create a ~/.ssh/config file entry for the host along the lines of



        Host somename
        Hostname 192.168.1.3
        User user
        IdentityFile /home/user/ssh/keys/server1key





        share|improve this answer



















        • 1




          I always assumed that the config file required indentation - I see that's not the case. Intruiging.
          – Boris the Spider
          Aug 7 at 19:10










        • Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
          – JW0914
          Aug 7 at 23:47










        • @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
          – Sebastian Stark
          Aug 13 at 0:04










        • @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
          – JW0914
          Aug 14 at 0:24














        up vote
        33
        down vote



        accepted










        It fails for the same reason that ssh-copy-id failed the first time - i.e. because you have chosen a non-default location for the identity file.



        You can resolve it in the same way, by adding -i /home/user/ssh/keys/server1key to your ssh command - note that the client side needs the location of the private key file.



        From man ssh



         -i identity_file
        Selects a file from which the identity (private key) for public
        key authentication is read. The default is ~/.ssh/identity for
        protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
        ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.


        Alternatively, you may wish to create a ~/.ssh/config file entry for the host along the lines of



        Host somename
        Hostname 192.168.1.3
        User user
        IdentityFile /home/user/ssh/keys/server1key





        share|improve this answer



















        • 1




          I always assumed that the config file required indentation - I see that's not the case. Intruiging.
          – Boris the Spider
          Aug 7 at 19:10










        • Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
          – JW0914
          Aug 7 at 23:47










        • @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
          – Sebastian Stark
          Aug 13 at 0:04










        • @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
          – JW0914
          Aug 14 at 0:24












        up vote
        33
        down vote



        accepted







        up vote
        33
        down vote



        accepted






        It fails for the same reason that ssh-copy-id failed the first time - i.e. because you have chosen a non-default location for the identity file.



        You can resolve it in the same way, by adding -i /home/user/ssh/keys/server1key to your ssh command - note that the client side needs the location of the private key file.



        From man ssh



         -i identity_file
        Selects a file from which the identity (private key) for public
        key authentication is read. The default is ~/.ssh/identity for
        protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
        ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.


        Alternatively, you may wish to create a ~/.ssh/config file entry for the host along the lines of



        Host somename
        Hostname 192.168.1.3
        User user
        IdentityFile /home/user/ssh/keys/server1key





        share|improve this answer















        It fails for the same reason that ssh-copy-id failed the first time - i.e. because you have chosen a non-default location for the identity file.



        You can resolve it in the same way, by adding -i /home/user/ssh/keys/server1key to your ssh command - note that the client side needs the location of the private key file.



        From man ssh



         -i identity_file
        Selects a file from which the identity (private key) for public
        key authentication is read. The default is ~/.ssh/identity for
        protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
        ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.


        Alternatively, you may wish to create a ~/.ssh/config file entry for the host along the lines of



        Host somename
        Hostname 192.168.1.3
        User user
        IdentityFile /home/user/ssh/keys/server1key






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited Aug 8 at 3:12


























        answered Aug 7 at 18:24









        steeldriver

        62k1196163




        62k1196163







        • 1




          I always assumed that the config file required indentation - I see that's not the case. Intruiging.
          – Boris the Spider
          Aug 7 at 19:10










        • Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
          – JW0914
          Aug 7 at 23:47










        • @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
          – Sebastian Stark
          Aug 13 at 0:04










        • @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
          – JW0914
          Aug 14 at 0:24












        • 1




          I always assumed that the config file required indentation - I see that's not the case. Intruiging.
          – Boris the Spider
          Aug 7 at 19:10










        • Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
          – JW0914
          Aug 7 at 23:47










        • @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
          – Sebastian Stark
          Aug 13 at 0:04










        • @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
          – JW0914
          Aug 14 at 0:24







        1




        1




        I always assumed that the config file required indentation - I see that's not the case. Intruiging.
        – Boris the Spider
        Aug 7 at 19:10




        I always assumed that the config file required indentation - I see that's not the case. Intruiging.
        – Boris the Spider
        Aug 7 at 19:10












        Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
        – JW0914
        Aug 7 at 23:47




        Anyone using OpenSSH should have a ~/.ssh/config, otherwise OpenSSH uses the system wide default /etc/ssh/ssh_config. In case anyone finds it helpful, I uploaded a pre-built ssh_config to my GitHub a while back as a starting point for users who may not have time to read the ssh_config man page
        – JW0914
        Aug 7 at 23:47












        @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
        – Sebastian Stark
        Aug 13 at 0:04




        @JW0914 that's only half true: individual values in ~/.ssh/config will override those of the global ssh_config, but just having the file will not disable the system wide configuration.
        – Sebastian Stark
        Aug 13 at 0:04












        @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
        – JW0914
        Aug 14 at 0:24




        @SebastianStark Perhaps you misread my comment, as I never stated it would disable the system wide configuration. What I stated was 100% factually accurate.
        – JW0914
        Aug 14 at 0:24












        up vote
        2
        down vote













        Another reason that ssh-copy-id fails, is because the key isn't added to the ssh agent.



        First check and start if ssh-agemt is running



        $ eval "$(ssh-agent -s)"


        If you get in process ID, you can add your key



        $ ssh-add -k /home/user/ssh/keys/server1key


        With -k you add the key to the keychain



        Check if key's are added with



        $ ssh-add -l


        Ssh-copy-id should working now.






        share|improve this answer

























          up vote
          2
          down vote













          Another reason that ssh-copy-id fails, is because the key isn't added to the ssh agent.



          First check and start if ssh-agemt is running



          $ eval "$(ssh-agent -s)"


          If you get in process ID, you can add your key



          $ ssh-add -k /home/user/ssh/keys/server1key


          With -k you add the key to the keychain



          Check if key's are added with



          $ ssh-add -l


          Ssh-copy-id should working now.






          share|improve this answer























            up vote
            2
            down vote










            up vote
            2
            down vote









            Another reason that ssh-copy-id fails, is because the key isn't added to the ssh agent.



            First check and start if ssh-agemt is running



            $ eval "$(ssh-agent -s)"


            If you get in process ID, you can add your key



            $ ssh-add -k /home/user/ssh/keys/server1key


            With -k you add the key to the keychain



            Check if key's are added with



            $ ssh-add -l


            Ssh-copy-id should working now.






            share|improve this answer













            Another reason that ssh-copy-id fails, is because the key isn't added to the ssh agent.



            First check and start if ssh-agemt is running



            $ eval "$(ssh-agent -s)"


            If you get in process ID, you can add your key



            $ ssh-add -k /home/user/ssh/keys/server1key


            With -k you add the key to the keychain



            Check if key's are added with



            $ ssh-add -l


            Ssh-copy-id should working now.







            share|improve this answer













            share|improve this answer



            share|improve this answer











            answered Aug 7 at 22:40









            Martijn

            212




            212




















                up vote
                -1
                down vote













                Hope this will work for you.. "sshpass -p yourpassword" it will automatically login to remote host.



                [root@localhost .ssh]# sshpass -p password123 ssh -l root localhost






                share|improve this answer

























                  up vote
                  -1
                  down vote













                  Hope this will work for you.. "sshpass -p yourpassword" it will automatically login to remote host.



                  [root@localhost .ssh]# sshpass -p password123 ssh -l root localhost






                  share|improve this answer























                    up vote
                    -1
                    down vote










                    up vote
                    -1
                    down vote









                    Hope this will work for you.. "sshpass -p yourpassword" it will automatically login to remote host.



                    [root@localhost .ssh]# sshpass -p password123 ssh -l root localhost






                    share|improve this answer













                    Hope this will work for you.. "sshpass -p yourpassword" it will automatically login to remote host.



                    [root@localhost .ssh]# sshpass -p password123 ssh -l root localhost







                    share|improve this answer













                    share|improve this answer



                    share|improve this answer











                    answered Aug 13 at 22:39









                    Khandu Aargade

                    523




                    523




















                        up vote
                        -1
                        down vote













                        Just execute 2 commands:



                        ssh-keygen
                        ssh-copy-id


                        Long answer:



                        user@ip:~$ ssh-keygen
                        Generating public/private rsa key pair.
                        Enter file in which to save the key (/home/user/.ssh/id_rsa): temp_file
                        Enter passphrase (empty for no passphrase):
                        Enter same passphrase again:
                        Your identification has been saved in stemp.
                        Your public key has been saved in stemp.pub.
                        The key fingerprint is:
                        SHA256:5**M user@ip
                        The key's randomart image is:
                        +---[RSA 2048]----+
                        | ... |
                        | ... |
                        | .. |
                        | ..+. o . |
                        | |
                        | B |
                        | |
                        |= * |
                        |=+ o . |
                        +----[SHA256]-----+


                        And then:



                        user@ip:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub ipDestination -p portDest





                        share|improve this answer

























                          up vote
                          -1
                          down vote













                          Just execute 2 commands:



                          ssh-keygen
                          ssh-copy-id


                          Long answer:



                          user@ip:~$ ssh-keygen
                          Generating public/private rsa key pair.
                          Enter file in which to save the key (/home/user/.ssh/id_rsa): temp_file
                          Enter passphrase (empty for no passphrase):
                          Enter same passphrase again:
                          Your identification has been saved in stemp.
                          Your public key has been saved in stemp.pub.
                          The key fingerprint is:
                          SHA256:5**M user@ip
                          The key's randomart image is:
                          +---[RSA 2048]----+
                          | ... |
                          | ... |
                          | .. |
                          | ..+. o . |
                          | |
                          | B |
                          | |
                          |= * |
                          |=+ o . |
                          +----[SHA256]-----+


                          And then:



                          user@ip:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub ipDestination -p portDest





                          share|improve this answer























                            up vote
                            -1
                            down vote










                            up vote
                            -1
                            down vote









                            Just execute 2 commands:



                            ssh-keygen
                            ssh-copy-id


                            Long answer:



                            user@ip:~$ ssh-keygen
                            Generating public/private rsa key pair.
                            Enter file in which to save the key (/home/user/.ssh/id_rsa): temp_file
                            Enter passphrase (empty for no passphrase):
                            Enter same passphrase again:
                            Your identification has been saved in stemp.
                            Your public key has been saved in stemp.pub.
                            The key fingerprint is:
                            SHA256:5**M user@ip
                            The key's randomart image is:
                            +---[RSA 2048]----+
                            | ... |
                            | ... |
                            | .. |
                            | ..+. o . |
                            | |
                            | B |
                            | |
                            |= * |
                            |=+ o . |
                            +----[SHA256]-----+


                            And then:



                            user@ip:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub ipDestination -p portDest





                            share|improve this answer













                            Just execute 2 commands:



                            ssh-keygen
                            ssh-copy-id


                            Long answer:



                            user@ip:~$ ssh-keygen
                            Generating public/private rsa key pair.
                            Enter file in which to save the key (/home/user/.ssh/id_rsa): temp_file
                            Enter passphrase (empty for no passphrase):
                            Enter same passphrase again:
                            Your identification has been saved in stemp.
                            Your public key has been saved in stemp.pub.
                            The key fingerprint is:
                            SHA256:5**M user@ip
                            The key's randomart image is:
                            +---[RSA 2048]----+
                            | ... |
                            | ... |
                            | .. |
                            | ..+. o . |
                            | |
                            | B |
                            | |
                            |= * |
                            |=+ o . |
                            +----[SHA256]-----+


                            And then:



                            user@ip:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub ipDestination -p portDest






                            share|improve this answer













                            share|improve this answer



                            share|improve this answer











                            answered Aug 16 at 7:25









                            Mohsen Abasi

                            991




                            991






















                                 

                                draft saved


                                draft discarded


























                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1063287%2fssh-without-password-with-non-default-identity-file-location%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                這個網誌中的熱門文章

                                How to combine Bézier curves to a surface?

                                Mutual Information Always Non-negative

                                Why am i infinitely getting the same tweet with the Twitter Search API?