Is there an equivalent to ssh-copy-id for Windows?Useful Command-line Commands on WindowsQuickest way to...

Where would I need my direct neural interface to be implanted?

meaning of 腰を落としている

Why is the sentence "Das ist eine Nase" correct?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Is this answer explanation correct?

Theorists sure want true answers to this!

What historical events would have to change in order to make 19th century "steampunk" technology possible?

What is an equivalently powerful replacement spell for the Yuan-Ti's Suggestion spell?

How much mains leakage does an Ethernet connection to a PC induce, and what is the operating leakage path?

Do Iron Man suits sport waste management systems?

Bullying boss launched a smear campaign and made me unemployable

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

Car headlights in a world without electricity

Why was Sir Cadogan fired?

Notepad++ delete until colon for every line with replace all

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?

Why didn't Boeing produce its own regional jet?

What is a Samsaran Word™?

Getting extremely large arrows with tikzcd

Can someone clarify Hamming's notion of important problems in relation to modern academia?

What are the G forces leaving Earth orbit?

One verb to replace 'be a member of' a club

How to show a landlord what we have in savings?

What Exploit Are These User Agents Trying to Use?



Is there an equivalent to ssh-copy-id for Windows?


Useful Command-line Commands on WindowsQuickest way to transfer a file from remote Linux to Windows?SSH key setup for Joyent Node SmartMachine and Windows?Installing ssh keyIs my password compromised because I forgot to hit Enter after ssh username?Laravel Forge SSH on windows not recognizedSSH `-b` option in PuTTY/KiTTYSame SSH login process works for user A but not for user BSSH Remote Port Forwarding to specific userRDP equivalent to SSH port forwarding?













55















Is there any equivalent or port of ssh-copy-id available for Windows? That is, is there an easy way to transfer SSH keys from a local machine to a remote server under Windows?



In case it helps, I'm using Pageant and Kitty (a Putty alternative) already.










share|improve this question





























    55















    Is there any equivalent or port of ssh-copy-id available for Windows? That is, is there an easy way to transfer SSH keys from a local machine to a remote server under Windows?



    In case it helps, I'm using Pageant and Kitty (a Putty alternative) already.










    share|improve this question



























      55












      55








      55


      24






      Is there any equivalent or port of ssh-copy-id available for Windows? That is, is there an easy way to transfer SSH keys from a local machine to a remote server under Windows?



      In case it helps, I'm using Pageant and Kitty (a Putty alternative) already.










      share|improve this question
















      Is there any equivalent or port of ssh-copy-id available for Windows? That is, is there an easy way to transfer SSH keys from a local machine to a remote server under Windows?



      In case it helps, I'm using Pageant and Kitty (a Putty alternative) already.







      windows ssh port file-transfer ssh-keys






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 20 '11 at 18:48









      mrdenny

      26.4k43466




      26.4k43466










      asked Jan 20 '11 at 18:34









      Matt V.Matt V.

      4721512




      4721512






















          11 Answers
          11






          active

          oldest

          votes


















          26














          ssh-copy-id is a pretty simple script that should be pretty easy to replicate under windows.



          If you ignore all the parameter handling, error handling, and so on, these are the two commands from ssh-copy-id that are actually doing the work most of the time.



          GET_ID="cat ${ID_FILE}"
          { eval "$GET_ID" ; } | ssh ${1%:} "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1


          Using the putty tools a command like this should be equivalent (not tested).



          type  public_id | plink.exe username@hostname "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"


          If you want to do all the same error handling, and the automatic key location, I am sure writing a script under Windows will be a lot trickier, but certainly possible.






          share|improve this answer



















          • 1





            Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

            – Matt V.
            Jan 20 '11 at 22:45













          • Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

            – Zoredache
            Jan 20 '11 at 23:17






          • 4





            plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

            – KCD
            Apr 15 '14 at 0:50











          • @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

            – pabouk
            Oct 2 '16 at 20:57



















          19














          These answers didn't help me out. I really didn't need any crazy scripts.
          I had created a public key on my client machine in git bash and was trying to copy it to a VPS.



          After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"



          So use this command:
          cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace 123.45.67.89 with your machine / host / VPS's IP address.



          If the directory .ssh is not yet created on the host machine, use this small variation:
          cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"






          share|improve this answer



















          • 1





            Wish I had more votes! 👍 for the one-liner!

            – patricktokeeffe
            Oct 5 '18 at 20:47



















          16














          ssh-copy-id does a couple of things (read the man page for details), but the most important thing it does is append the contents of your local public key file to a remote file called authorized_keys.




          • You could do this yourself by opening the key file with a text editor and pasting the contents in the Kitty terminal.
            echo 'long_line_with_contents_of_public_key_file' >> .ssh/authorized_keys


          • Alternatively, you could upload the file using WinSCP (which uses sftp, or scp as a fallback) and do something similar to my previous suggestion, without the ugly copy/pasting.
            cat id_rsa.pub >> .ssh/authorized_keys

            where id_rsa.pub is the filename of the public key you uploaded.







          share|improve this answer

































            5














            Inspired by zoredache's answer, I've created a bunch of scripts that are the windows version. However they all depend on plink.
            Please take a look here



            https://github.com/VijayS1/Scripts/blob/master/ssh-copy-id/



            I also have a winscp script that can be used as per another answer. :)
            Excerpt from the readme:



            Attempted methods so far:




            • DOS(.cmd) - Success


              • usage: .Scriptname test@example.com password [identity file]



            • VBS (.vbs) - Success


              • usage: .Scriptname /i:idtest.pub user@example.com /p:password



            • Powershell(.ps1) - Success



              • usage: .Scriptname -i idtest.pub user@example.com password



            • mremoteNG (ext app) - Success


              • Select Host, right click, external tools, select Scriptname



            • WinSCP script (.bat) - Success



              • # "WinSCP.com" /script=".Scriptname" /parameter "user[:password]@example.com" "id_rsa.pub" [/log=".copyssh.log]"








            share|improve this answer





















            • 1





              These are pretty sweet

              – Pred
              Jul 29 '15 at 16:18



















            5














            In Windows 7 there is a ssh.exe



            Here is what worked for me:



            1. create identity (on windows)



            c:>ssh-keygen


            That created an identity file in the home directory.
            I changed the name of the public key to "id_rsa"



            2. copy the file to the target linux system using the ssh
            Credits to https://serverfault.com/users/984/zoredache for his answer



            c:>ssh user@lnxhost "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" < \path_to_where_the_file_was_generated_from_ssh_key_genid_rsa.pub


            Note: For some reason piping didn't work for me:



            # this should work but it didn't work for me 
            type file | ssh user@lnxhost "cat >> /tmp/t.txt"


            3. Correct the file on linux
            The id_rsa.pub file on windows is multiline where linux expects it in in a single line so we have to correct it a bit. Login to linux and open the file:



            vi ~/.ssh/authorized_keys


            For example:



            ---- BEGIN SSH2 PUBLIC KEY ----
            Comment: "2048-bit RSA, user@winhost"
            AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla33
            5flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMC
            Y58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVy
            ax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdT
            LFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHE
            Qkw+1wuV6dFoT1/hngSw==
            ---- END SSH2 PUBLIC KEY ----


            should become



            ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla335flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMCY58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVyax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdTLFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHEQkw+1wuV6dFoT1/hngSw== user@winhost


            4. test it



            c:>ssh user@lnxhost "ls -al /tmp/"


            This should list the content of /tmp without asking for the password.






            share|improve this answer





















            • 1





              👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

              – patricktokeeffe
              Feb 15 '18 at 20:27











            • happy it helped you - up vote the answer :)

              – Deian
              Feb 16 '18 at 16:24



















            5














            If you do not have ssh-copy-id on Windows, you can run it on the server itself.




            • In PuTTYgen, load your private key (.ppk);

            • Copy the contents of the box Public key for pasting into OpenSSH authorized_keys file to a clipboard.

            • Paste it into your favorite editor (Windows Notepad will do).

            • Save the contents to a file with .pub extension.

            • Upload the .pub file to the server.

            • Login to the server with an SSH client, like PuTTY.


            • On the server type:



              ssh-copy-id -i mykey.pub username@localhost





            On Windows ssh-copy-id script comes with Git for Windows. So you may use that locally, if you have Git for Windows.





            If you do not want to do this manually, you can use WinSCP 5.15. It can setup the public key authentication for you.

            Use Tools > Install Public Key into Server button on SSH > Authentication page of WinSCP Advanced Site Settings dialog.



            enter image description here



            (I'm the author of WinSCP)






            share|improve this answer


























            • This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

              – Alex
              yesterday



















            0














            If you are using cmder (or msysgit/mingw that has scp & ssh), I just wrote a simple python script for this. It can be found here: https://gist.github.com/ceilfors/fb6908dc8ac96e8fc983



            Sample usage: python ssh-copy-id.py user@remote-machine.



            Password will be prompted upon running the script.






            share|improve this answer
























            • why does this require cmder?

              – David Zorychta
              Jan 7 '16 at 3:39











            • @user57411 It doesn't require cmder, it requires scp and ssh commands.

              – ceilfors
              Jan 7 '16 at 6:49



















            0














            what i did, having CygWin on my Win10, connecting to Linux (based on aboves answer):



            - note: using cat, it would resolve the cygwin path automatically, as well as any cygwin command using the cygwin-linux-folder-structure



            1. added c:cygwinbin to the environment's Path variable
            2. starting cmd.exe (windows commandline)
            3. > ssh-keygen -t rsa (just pressing enter till done)
            4. > cat ~/.ssh/id_rsa.pub | ssh user@server "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys"
            5. ..enter server password
            6. > ssh user@server (testing, not beeing asked for password)





            share|improve this answer































              0














              This following steps would do:



              STEP-1: Generate RSA Key Pair



              C:Usersuser>ssh-keygen
              Generating public/private rsa key pair.
              Enter file in which to save the key (/c/Users/user//.ssh/id_rsa):
              Enter passphrase (empty for no passphrase):
              Enter same passphrase again:
              Your identification has been saved in /c/Users/user//.ssh/id_rsa.
              Your public key has been saved in /c/Users/user//.ssh/id_rsa.pub.
              The key fingerprint is:
              20:16:9b:0d:00:92:c4:34:99:51:20:b7:ef:50:c4:0f user@localhost


              STE2-2: ssh-copy-id equivalent in windows



              C:Usersuser>ssh user@remote "umask 077; test -d .ssh || mkdir .ssh ; cat >> .s
              sh/authorized_keys || exit 1" < "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys
              || exit 1" < C:Usersuser.sshid_rsa.pub
              The authenticity of host 'remote (xx.xx.xxx.xx)' can't be established.
              RSA key fingerprint is 99:99:73:74:fe:14:bc:91:c8:3b:ac:f4:95:99:4d:06.
              Are you sure you want to continue connecting (yes/no)? yes
              Warning: Permanently added 'remote,xx.xx.xxx.xx' (RSA) to the list of known hosts.
              *************************************************************************
              This computer system is the property of Sample Corporation and is to
              be used for business purposes. All information, messages, software and
              hardware created, stored, accessed, received, or used by you through
              this system is considered to be the sole property of Sample Corporation
              and can and may be monitored, reviewed, and retained at any time. You
              should have no expectation that any such information, messages or
              material will be private. By accessing and using this computer, you
              acknowledge and consent to such monitoring and information retrieval.
              By accessing and using this computer, you also agree to comply with
              all of Sample Company's policies and standards.
              *************************************************************************
              user@remote's password:[Enter Password for first time]


              STEP-3: Passwordless authentication works!



              C:Usersuser>ssh user@remote
              *************************************************************************
              This computer system is the property of Sample Corporation and is to
              be used for business purposes. All information, messages, software and
              hardware created, stored, accessed, received, or used by you through
              this system is considered to be the sole property of Sample Corporation
              and can and may be monitored, reviewed, and retained at any time. You
              should have no expectation that any such information, messages or
              material will be private. By accessing and using this computer, you
              acknowledge and consent to such monitoring and information retrieval.
              By accessing and using this computer, you also agree to comply with
              all of Sample Company's policies and standards.
              *************************************************************************
              Last login: Wed Oct 14 14:37:13 2015 from localhost





              share|improve this answer

































                0














                There is a Windows version of ssh-copy-id I found on GitHub:
                https://github.com/zhengyi-yang/ssh-copy-id/tree/master/dist






                share|improve this answer































                  0














                  Powershell version for SSH included in Git For Windows



                  In fact, it can work as long as you have ssh in your path.
                  Add the following in your powershell profile:



                  function ssh-copy-id([string]$userAtMachine){   
                  $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
                  if (!(Test-Path "$publicKey")){
                  Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
                  }
                  else {
                  & cat "$publicKey" | ssh $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
                  }
                  }


                  In a powershell console:



                  ssh-copy-id user@machine





                  share|improve this answer


























                  • ssh-copy-id is not supposed to generate a key if it doesn't exist.

                    – RalfFriedl
                    Dec 9 '18 at 12:05











                  • @RalfFriedl I removed the keygen

                    – Fab
                    Dec 11 '18 at 14:26












                  Your Answer








                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "2"
                  };
                  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%2fserverfault.com%2fquestions%2f224810%2fis-there-an-equivalent-to-ssh-copy-id-for-windows%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  11 Answers
                  11






                  active

                  oldest

                  votes








                  11 Answers
                  11






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  26














                  ssh-copy-id is a pretty simple script that should be pretty easy to replicate under windows.



                  If you ignore all the parameter handling, error handling, and so on, these are the two commands from ssh-copy-id that are actually doing the work most of the time.



                  GET_ID="cat ${ID_FILE}"
                  { eval "$GET_ID" ; } | ssh ${1%:} "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1


                  Using the putty tools a command like this should be equivalent (not tested).



                  type  public_id | plink.exe username@hostname "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"


                  If you want to do all the same error handling, and the automatic key location, I am sure writing a script under Windows will be a lot trickier, but certainly possible.






                  share|improve this answer



















                  • 1





                    Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

                    – Matt V.
                    Jan 20 '11 at 22:45













                  • Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

                    – Zoredache
                    Jan 20 '11 at 23:17






                  • 4





                    plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

                    – KCD
                    Apr 15 '14 at 0:50











                  • @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

                    – pabouk
                    Oct 2 '16 at 20:57
















                  26














                  ssh-copy-id is a pretty simple script that should be pretty easy to replicate under windows.



                  If you ignore all the parameter handling, error handling, and so on, these are the two commands from ssh-copy-id that are actually doing the work most of the time.



                  GET_ID="cat ${ID_FILE}"
                  { eval "$GET_ID" ; } | ssh ${1%:} "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1


                  Using the putty tools a command like this should be equivalent (not tested).



                  type  public_id | plink.exe username@hostname "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"


                  If you want to do all the same error handling, and the automatic key location, I am sure writing a script under Windows will be a lot trickier, but certainly possible.






                  share|improve this answer



















                  • 1





                    Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

                    – Matt V.
                    Jan 20 '11 at 22:45













                  • Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

                    – Zoredache
                    Jan 20 '11 at 23:17






                  • 4





                    plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

                    – KCD
                    Apr 15 '14 at 0:50











                  • @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

                    – pabouk
                    Oct 2 '16 at 20:57














                  26












                  26








                  26







                  ssh-copy-id is a pretty simple script that should be pretty easy to replicate under windows.



                  If you ignore all the parameter handling, error handling, and so on, these are the two commands from ssh-copy-id that are actually doing the work most of the time.



                  GET_ID="cat ${ID_FILE}"
                  { eval "$GET_ID" ; } | ssh ${1%:} "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1


                  Using the putty tools a command like this should be equivalent (not tested).



                  type  public_id | plink.exe username@hostname "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"


                  If you want to do all the same error handling, and the automatic key location, I am sure writing a script under Windows will be a lot trickier, but certainly possible.






                  share|improve this answer













                  ssh-copy-id is a pretty simple script that should be pretty easy to replicate under windows.



                  If you ignore all the parameter handling, error handling, and so on, these are the two commands from ssh-copy-id that are actually doing the work most of the time.



                  GET_ID="cat ${ID_FILE}"
                  { eval "$GET_ID" ; } | ssh ${1%:} "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1


                  Using the putty tools a command like this should be equivalent (not tested).



                  type  public_id | plink.exe username@hostname "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys"


                  If you want to do all the same error handling, and the automatic key location, I am sure writing a script under Windows will be a lot trickier, but certainly possible.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 20 '11 at 20:09









                  ZoredacheZoredache

                  111k30231379




                  111k30231379








                  • 1





                    Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

                    – Matt V.
                    Jan 20 '11 at 22:45













                  • Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

                    – Zoredache
                    Jan 20 '11 at 23:17






                  • 4





                    plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

                    – KCD
                    Apr 15 '14 at 0:50











                  • @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

                    – pabouk
                    Oct 2 '16 at 20:57














                  • 1





                    Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

                    – Matt V.
                    Jan 20 '11 at 22:45













                  • Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

                    – Zoredache
                    Jan 20 '11 at 23:17






                  • 4





                    plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

                    – KCD
                    Apr 15 '14 at 0:50











                  • @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

                    – pabouk
                    Oct 2 '16 at 20:57








                  1




                  1





                  Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

                  – Matt V.
                  Jan 20 '11 at 22:45







                  Thanks! I couldn't get it to work at first; I was getting "access denied" errors back, but plink wasn't stopping to let me enter the password. I then tried passing plink the password using the -pw switch and that worked. Do you know if there is a way to get plink to pause for you to enter the password mid-way through?

                  – Matt V.
                  Jan 20 '11 at 22:45















                  Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

                  – Zoredache
                  Jan 20 '11 at 23:17





                  Not really sure about password authentication and plink. Whenever I actually use it I already have my key on the system, and I have pagent running.

                  – Zoredache
                  Jan 20 '11 at 23:17




                  4




                  4





                  plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

                  – KCD
                  Apr 15 '14 at 0:50





                  plink.exe -pw password works. Also if you know .ssh/authorized_keys exists the command is simply type id_rsa.pub | plink.exe -ssh user@host -pw password "cat >> .ssh/authorized_keys"

                  – KCD
                  Apr 15 '14 at 0:50













                  @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

                  – pabouk
                  Oct 2 '16 at 20:57





                  @KCD It is sufficient if the .ssh/ directory exists. The >> redirection will then create the file if it does not exist.

                  – pabouk
                  Oct 2 '16 at 20:57













                  19














                  These answers didn't help me out. I really didn't need any crazy scripts.
                  I had created a public key on my client machine in git bash and was trying to copy it to a VPS.



                  After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"



                  So use this command:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace 123.45.67.89 with your machine / host / VPS's IP address.



                  If the directory .ssh is not yet created on the host machine, use this small variation:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"






                  share|improve this answer



















                  • 1





                    Wish I had more votes! 👍 for the one-liner!

                    – patricktokeeffe
                    Oct 5 '18 at 20:47
















                  19














                  These answers didn't help me out. I really didn't need any crazy scripts.
                  I had created a public key on my client machine in git bash and was trying to copy it to a VPS.



                  After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"



                  So use this command:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace 123.45.67.89 with your machine / host / VPS's IP address.



                  If the directory .ssh is not yet created on the host machine, use this small variation:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"






                  share|improve this answer



















                  • 1





                    Wish I had more votes! 👍 for the one-liner!

                    – patricktokeeffe
                    Oct 5 '18 at 20:47














                  19












                  19








                  19







                  These answers didn't help me out. I really didn't need any crazy scripts.
                  I had created a public key on my client machine in git bash and was trying to copy it to a VPS.



                  After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"



                  So use this command:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace 123.45.67.89 with your machine / host / VPS's IP address.



                  If the directory .ssh is not yet created on the host machine, use this small variation:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"






                  share|improve this answer













                  These answers didn't help me out. I really didn't need any crazy scripts.
                  I had created a public key on my client machine in git bash and was trying to copy it to a VPS.



                  After creating your public key, the key should be stored as "(whatever folder you started in)/.ssh/id_rsa.pub"



                  So use this command:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" where user is your username (sometimes "root", or whatever you may have set up), and replace 123.45.67.89 with your machine / host / VPS's IP address.



                  If the directory .ssh is not yet created on the host machine, use this small variation:
                  cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 21 '14 at 11:53









                  Augie GardnerAugie Gardner

                  29123




                  29123








                  • 1





                    Wish I had more votes! 👍 for the one-liner!

                    – patricktokeeffe
                    Oct 5 '18 at 20:47














                  • 1





                    Wish I had more votes! 👍 for the one-liner!

                    – patricktokeeffe
                    Oct 5 '18 at 20:47








                  1




                  1





                  Wish I had more votes! 👍 for the one-liner!

                  – patricktokeeffe
                  Oct 5 '18 at 20:47





                  Wish I had more votes! 👍 for the one-liner!

                  – patricktokeeffe
                  Oct 5 '18 at 20:47











                  16














                  ssh-copy-id does a couple of things (read the man page for details), but the most important thing it does is append the contents of your local public key file to a remote file called authorized_keys.




                  • You could do this yourself by opening the key file with a text editor and pasting the contents in the Kitty terminal.
                    echo 'long_line_with_contents_of_public_key_file' >> .ssh/authorized_keys


                  • Alternatively, you could upload the file using WinSCP (which uses sftp, or scp as a fallback) and do something similar to my previous suggestion, without the ugly copy/pasting.
                    cat id_rsa.pub >> .ssh/authorized_keys

                    where id_rsa.pub is the filename of the public key you uploaded.







                  share|improve this answer






























                    16














                    ssh-copy-id does a couple of things (read the man page for details), but the most important thing it does is append the contents of your local public key file to a remote file called authorized_keys.




                    • You could do this yourself by opening the key file with a text editor and pasting the contents in the Kitty terminal.
                      echo 'long_line_with_contents_of_public_key_file' >> .ssh/authorized_keys


                    • Alternatively, you could upload the file using WinSCP (which uses sftp, or scp as a fallback) and do something similar to my previous suggestion, without the ugly copy/pasting.
                      cat id_rsa.pub >> .ssh/authorized_keys

                      where id_rsa.pub is the filename of the public key you uploaded.







                    share|improve this answer




























                      16












                      16








                      16







                      ssh-copy-id does a couple of things (read the man page for details), but the most important thing it does is append the contents of your local public key file to a remote file called authorized_keys.




                      • You could do this yourself by opening the key file with a text editor and pasting the contents in the Kitty terminal.
                        echo 'long_line_with_contents_of_public_key_file' >> .ssh/authorized_keys


                      • Alternatively, you could upload the file using WinSCP (which uses sftp, or scp as a fallback) and do something similar to my previous suggestion, without the ugly copy/pasting.
                        cat id_rsa.pub >> .ssh/authorized_keys

                        where id_rsa.pub is the filename of the public key you uploaded.







                      share|improve this answer















                      ssh-copy-id does a couple of things (read the man page for details), but the most important thing it does is append the contents of your local public key file to a remote file called authorized_keys.




                      • You could do this yourself by opening the key file with a text editor and pasting the contents in the Kitty terminal.
                        echo 'long_line_with_contents_of_public_key_file' >> .ssh/authorized_keys


                      • Alternatively, you could upload the file using WinSCP (which uses sftp, or scp as a fallback) and do something similar to my previous suggestion, without the ugly copy/pasting.
                        cat id_rsa.pub >> .ssh/authorized_keys

                        where id_rsa.pub is the filename of the public key you uploaded.








                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 20 '11 at 20:23









                      Iain

                      105k13164258




                      105k13164258










                      answered Jan 20 '11 at 18:55









                      Kenny RasschaertKenny Rasschaert

                      7,73733455




                      7,73733455























                          5














                          Inspired by zoredache's answer, I've created a bunch of scripts that are the windows version. However they all depend on plink.
                          Please take a look here



                          https://github.com/VijayS1/Scripts/blob/master/ssh-copy-id/



                          I also have a winscp script that can be used as per another answer. :)
                          Excerpt from the readme:



                          Attempted methods so far:




                          • DOS(.cmd) - Success


                            • usage: .Scriptname test@example.com password [identity file]



                          • VBS (.vbs) - Success


                            • usage: .Scriptname /i:idtest.pub user@example.com /p:password



                          • Powershell(.ps1) - Success



                            • usage: .Scriptname -i idtest.pub user@example.com password



                          • mremoteNG (ext app) - Success


                            • Select Host, right click, external tools, select Scriptname



                          • WinSCP script (.bat) - Success



                            • # "WinSCP.com" /script=".Scriptname" /parameter "user[:password]@example.com" "id_rsa.pub" [/log=".copyssh.log]"








                          share|improve this answer





















                          • 1





                            These are pretty sweet

                            – Pred
                            Jul 29 '15 at 16:18
















                          5














                          Inspired by zoredache's answer, I've created a bunch of scripts that are the windows version. However they all depend on plink.
                          Please take a look here



                          https://github.com/VijayS1/Scripts/blob/master/ssh-copy-id/



                          I also have a winscp script that can be used as per another answer. :)
                          Excerpt from the readme:



                          Attempted methods so far:




                          • DOS(.cmd) - Success


                            • usage: .Scriptname test@example.com password [identity file]



                          • VBS (.vbs) - Success


                            • usage: .Scriptname /i:idtest.pub user@example.com /p:password



                          • Powershell(.ps1) - Success



                            • usage: .Scriptname -i idtest.pub user@example.com password



                          • mremoteNG (ext app) - Success


                            • Select Host, right click, external tools, select Scriptname



                          • WinSCP script (.bat) - Success



                            • # "WinSCP.com" /script=".Scriptname" /parameter "user[:password]@example.com" "id_rsa.pub" [/log=".copyssh.log]"








                          share|improve this answer





















                          • 1





                            These are pretty sweet

                            – Pred
                            Jul 29 '15 at 16:18














                          5












                          5








                          5







                          Inspired by zoredache's answer, I've created a bunch of scripts that are the windows version. However they all depend on plink.
                          Please take a look here



                          https://github.com/VijayS1/Scripts/blob/master/ssh-copy-id/



                          I also have a winscp script that can be used as per another answer. :)
                          Excerpt from the readme:



                          Attempted methods so far:




                          • DOS(.cmd) - Success


                            • usage: .Scriptname test@example.com password [identity file]



                          • VBS (.vbs) - Success


                            • usage: .Scriptname /i:idtest.pub user@example.com /p:password



                          • Powershell(.ps1) - Success



                            • usage: .Scriptname -i idtest.pub user@example.com password



                          • mremoteNG (ext app) - Success


                            • Select Host, right click, external tools, select Scriptname



                          • WinSCP script (.bat) - Success



                            • # "WinSCP.com" /script=".Scriptname" /parameter "user[:password]@example.com" "id_rsa.pub" [/log=".copyssh.log]"








                          share|improve this answer















                          Inspired by zoredache's answer, I've created a bunch of scripts that are the windows version. However they all depend on plink.
                          Please take a look here



                          https://github.com/VijayS1/Scripts/blob/master/ssh-copy-id/



                          I also have a winscp script that can be used as per another answer. :)
                          Excerpt from the readme:



                          Attempted methods so far:




                          • DOS(.cmd) - Success


                            • usage: .Scriptname test@example.com password [identity file]



                          • VBS (.vbs) - Success


                            • usage: .Scriptname /i:idtest.pub user@example.com /p:password



                          • Powershell(.ps1) - Success



                            • usage: .Scriptname -i idtest.pub user@example.com password



                          • mremoteNG (ext app) - Success


                            • Select Host, right click, external tools, select Scriptname



                          • WinSCP script (.bat) - Success



                            • # "WinSCP.com" /script=".Scriptname" /parameter "user[:password]@example.com" "id_rsa.pub" [/log=".copyssh.log]"









                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 28 '14 at 5:23

























                          answered Jan 27 '14 at 13:31









                          VijayVijay

                          222413




                          222413








                          • 1





                            These are pretty sweet

                            – Pred
                            Jul 29 '15 at 16:18














                          • 1





                            These are pretty sweet

                            – Pred
                            Jul 29 '15 at 16:18








                          1




                          1





                          These are pretty sweet

                          – Pred
                          Jul 29 '15 at 16:18





                          These are pretty sweet

                          – Pred
                          Jul 29 '15 at 16:18











                          5














                          In Windows 7 there is a ssh.exe



                          Here is what worked for me:



                          1. create identity (on windows)



                          c:>ssh-keygen


                          That created an identity file in the home directory.
                          I changed the name of the public key to "id_rsa"



                          2. copy the file to the target linux system using the ssh
                          Credits to https://serverfault.com/users/984/zoredache for his answer



                          c:>ssh user@lnxhost "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" < \path_to_where_the_file_was_generated_from_ssh_key_genid_rsa.pub


                          Note: For some reason piping didn't work for me:



                          # this should work but it didn't work for me 
                          type file | ssh user@lnxhost "cat >> /tmp/t.txt"


                          3. Correct the file on linux
                          The id_rsa.pub file on windows is multiline where linux expects it in in a single line so we have to correct it a bit. Login to linux and open the file:



                          vi ~/.ssh/authorized_keys


                          For example:



                          ---- BEGIN SSH2 PUBLIC KEY ----
                          Comment: "2048-bit RSA, user@winhost"
                          AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla33
                          5flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMC
                          Y58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVy
                          ax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdT
                          LFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHE
                          Qkw+1wuV6dFoT1/hngSw==
                          ---- END SSH2 PUBLIC KEY ----


                          should become



                          ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla335flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMCY58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVyax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdTLFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHEQkw+1wuV6dFoT1/hngSw== user@winhost


                          4. test it



                          c:>ssh user@lnxhost "ls -al /tmp/"


                          This should list the content of /tmp without asking for the password.






                          share|improve this answer





















                          • 1





                            👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

                            – patricktokeeffe
                            Feb 15 '18 at 20:27











                          • happy it helped you - up vote the answer :)

                            – Deian
                            Feb 16 '18 at 16:24
















                          5














                          In Windows 7 there is a ssh.exe



                          Here is what worked for me:



                          1. create identity (on windows)



                          c:>ssh-keygen


                          That created an identity file in the home directory.
                          I changed the name of the public key to "id_rsa"



                          2. copy the file to the target linux system using the ssh
                          Credits to https://serverfault.com/users/984/zoredache for his answer



                          c:>ssh user@lnxhost "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" < \path_to_where_the_file_was_generated_from_ssh_key_genid_rsa.pub


                          Note: For some reason piping didn't work for me:



                          # this should work but it didn't work for me 
                          type file | ssh user@lnxhost "cat >> /tmp/t.txt"


                          3. Correct the file on linux
                          The id_rsa.pub file on windows is multiline where linux expects it in in a single line so we have to correct it a bit. Login to linux and open the file:



                          vi ~/.ssh/authorized_keys


                          For example:



                          ---- BEGIN SSH2 PUBLIC KEY ----
                          Comment: "2048-bit RSA, user@winhost"
                          AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla33
                          5flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMC
                          Y58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVy
                          ax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdT
                          LFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHE
                          Qkw+1wuV6dFoT1/hngSw==
                          ---- END SSH2 PUBLIC KEY ----


                          should become



                          ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla335flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMCY58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVyax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdTLFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHEQkw+1wuV6dFoT1/hngSw== user@winhost


                          4. test it



                          c:>ssh user@lnxhost "ls -al /tmp/"


                          This should list the content of /tmp without asking for the password.






                          share|improve this answer





















                          • 1





                            👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

                            – patricktokeeffe
                            Feb 15 '18 at 20:27











                          • happy it helped you - up vote the answer :)

                            – Deian
                            Feb 16 '18 at 16:24














                          5












                          5








                          5







                          In Windows 7 there is a ssh.exe



                          Here is what worked for me:



                          1. create identity (on windows)



                          c:>ssh-keygen


                          That created an identity file in the home directory.
                          I changed the name of the public key to "id_rsa"



                          2. copy the file to the target linux system using the ssh
                          Credits to https://serverfault.com/users/984/zoredache for his answer



                          c:>ssh user@lnxhost "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" < \path_to_where_the_file_was_generated_from_ssh_key_genid_rsa.pub


                          Note: For some reason piping didn't work for me:



                          # this should work but it didn't work for me 
                          type file | ssh user@lnxhost "cat >> /tmp/t.txt"


                          3. Correct the file on linux
                          The id_rsa.pub file on windows is multiline where linux expects it in in a single line so we have to correct it a bit. Login to linux and open the file:



                          vi ~/.ssh/authorized_keys


                          For example:



                          ---- BEGIN SSH2 PUBLIC KEY ----
                          Comment: "2048-bit RSA, user@winhost"
                          AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla33
                          5flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMC
                          Y58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVy
                          ax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdT
                          LFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHE
                          Qkw+1wuV6dFoT1/hngSw==
                          ---- END SSH2 PUBLIC KEY ----


                          should become



                          ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla335flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMCY58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVyax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdTLFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHEQkw+1wuV6dFoT1/hngSw== user@winhost


                          4. test it



                          c:>ssh user@lnxhost "ls -al /tmp/"


                          This should list the content of /tmp without asking for the password.






                          share|improve this answer















                          In Windows 7 there is a ssh.exe



                          Here is what worked for me:



                          1. create identity (on windows)



                          c:>ssh-keygen


                          That created an identity file in the home directory.
                          I changed the name of the public key to "id_rsa"



                          2. copy the file to the target linux system using the ssh
                          Credits to https://serverfault.com/users/984/zoredache for his answer



                          c:>ssh user@lnxhost "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1" < \path_to_where_the_file_was_generated_from_ssh_key_genid_rsa.pub


                          Note: For some reason piping didn't work for me:



                          # this should work but it didn't work for me 
                          type file | ssh user@lnxhost "cat >> /tmp/t.txt"


                          3. Correct the file on linux
                          The id_rsa.pub file on windows is multiline where linux expects it in in a single line so we have to correct it a bit. Login to linux and open the file:



                          vi ~/.ssh/authorized_keys


                          For example:



                          ---- BEGIN SSH2 PUBLIC KEY ----
                          Comment: "2048-bit RSA, user@winhost"
                          AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla33
                          5flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMC
                          Y58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVy
                          ax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdT
                          LFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHE
                          Qkw+1wuV6dFoT1/hngSw==
                          ---- END SSH2 PUBLIC KEY ----


                          should become



                          ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnvYlVooXGoj3+7huZBUqf4wj57r25SHCKiiShyla335flX7Rsmb4meExpdh2NzfzffG15xl1wo0xBZ3HdZdqF2GUniEcNbtVjS1FKzQwPfsYPHMCY58qT0U2ZgK1zsXj2o0D2RWrCv3DFFfwUgNyZRYN2HK32umY6OmGSOVuJvIKhT+X6YaCVyax3CHv2ByB2OTBl9mh4nrwYAVXToT+X2psBE+MKB5R85lrUGkl3GtymTk10Dvf5O80exdTLFRMvkCA5RAIZgvxMk/bbNaH/0UHQoctX9oaDeKGWUPfVaknFBQdU9009+lK/ocAlKVNHEQkw+1wuV6dFoT1/hngSw== user@winhost


                          4. test it



                          c:>ssh user@lnxhost "ls -al /tmp/"


                          This should list the content of /tmp without asking for the password.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Apr 13 '17 at 12:14









                          Community

                          1




                          1










                          answered Apr 8 '15 at 19:20









                          DeianDeian

                          15113




                          15113








                          • 1





                            👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

                            – patricktokeeffe
                            Feb 15 '18 at 20:27











                          • happy it helped you - up vote the answer :)

                            – Deian
                            Feb 16 '18 at 16:24














                          • 1





                            👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

                            – patricktokeeffe
                            Feb 15 '18 at 20:27











                          • happy it helped you - up vote the answer :)

                            – Deian
                            Feb 16 '18 at 16:24








                          1




                          1





                          👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

                          – patricktokeeffe
                          Feb 15 '18 at 20:27





                          👍 for Step 3. Reformatting authorized_keys to single-lines is all I needed!

                          – patricktokeeffe
                          Feb 15 '18 at 20:27













                          happy it helped you - up vote the answer :)

                          – Deian
                          Feb 16 '18 at 16:24





                          happy it helped you - up vote the answer :)

                          – Deian
                          Feb 16 '18 at 16:24











                          5














                          If you do not have ssh-copy-id on Windows, you can run it on the server itself.




                          • In PuTTYgen, load your private key (.ppk);

                          • Copy the contents of the box Public key for pasting into OpenSSH authorized_keys file to a clipboard.

                          • Paste it into your favorite editor (Windows Notepad will do).

                          • Save the contents to a file with .pub extension.

                          • Upload the .pub file to the server.

                          • Login to the server with an SSH client, like PuTTY.


                          • On the server type:



                            ssh-copy-id -i mykey.pub username@localhost





                          On Windows ssh-copy-id script comes with Git for Windows. So you may use that locally, if you have Git for Windows.





                          If you do not want to do this manually, you can use WinSCP 5.15. It can setup the public key authentication for you.

                          Use Tools > Install Public Key into Server button on SSH > Authentication page of WinSCP Advanced Site Settings dialog.



                          enter image description here



                          (I'm the author of WinSCP)






                          share|improve this answer


























                          • This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

                            – Alex
                            yesterday
















                          5














                          If you do not have ssh-copy-id on Windows, you can run it on the server itself.




                          • In PuTTYgen, load your private key (.ppk);

                          • Copy the contents of the box Public key for pasting into OpenSSH authorized_keys file to a clipboard.

                          • Paste it into your favorite editor (Windows Notepad will do).

                          • Save the contents to a file with .pub extension.

                          • Upload the .pub file to the server.

                          • Login to the server with an SSH client, like PuTTY.


                          • On the server type:



                            ssh-copy-id -i mykey.pub username@localhost





                          On Windows ssh-copy-id script comes with Git for Windows. So you may use that locally, if you have Git for Windows.





                          If you do not want to do this manually, you can use WinSCP 5.15. It can setup the public key authentication for you.

                          Use Tools > Install Public Key into Server button on SSH > Authentication page of WinSCP Advanced Site Settings dialog.



                          enter image description here



                          (I'm the author of WinSCP)






                          share|improve this answer


























                          • This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

                            – Alex
                            yesterday














                          5












                          5








                          5







                          If you do not have ssh-copy-id on Windows, you can run it on the server itself.




                          • In PuTTYgen, load your private key (.ppk);

                          • Copy the contents of the box Public key for pasting into OpenSSH authorized_keys file to a clipboard.

                          • Paste it into your favorite editor (Windows Notepad will do).

                          • Save the contents to a file with .pub extension.

                          • Upload the .pub file to the server.

                          • Login to the server with an SSH client, like PuTTY.


                          • On the server type:



                            ssh-copy-id -i mykey.pub username@localhost





                          On Windows ssh-copy-id script comes with Git for Windows. So you may use that locally, if you have Git for Windows.





                          If you do not want to do this manually, you can use WinSCP 5.15. It can setup the public key authentication for you.

                          Use Tools > Install Public Key into Server button on SSH > Authentication page of WinSCP Advanced Site Settings dialog.



                          enter image description here



                          (I'm the author of WinSCP)






                          share|improve this answer















                          If you do not have ssh-copy-id on Windows, you can run it on the server itself.




                          • In PuTTYgen, load your private key (.ppk);

                          • Copy the contents of the box Public key for pasting into OpenSSH authorized_keys file to a clipboard.

                          • Paste it into your favorite editor (Windows Notepad will do).

                          • Save the contents to a file with .pub extension.

                          • Upload the .pub file to the server.

                          • Login to the server with an SSH client, like PuTTY.


                          • On the server type:



                            ssh-copy-id -i mykey.pub username@localhost





                          On Windows ssh-copy-id script comes with Git for Windows. So you may use that locally, if you have Git for Windows.





                          If you do not want to do this manually, you can use WinSCP 5.15. It can setup the public key authentication for you.

                          Use Tools > Install Public Key into Server button on SSH > Authentication page of WinSCP Advanced Site Settings dialog.



                          enter image description here



                          (I'm the author of WinSCP)







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 4 mins ago

























                          answered Nov 19 '18 at 10:24









                          Martin PrikrylMartin Prikryl

                          5,2712458




                          5,2712458













                          • This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

                            – Alex
                            yesterday



















                          • This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

                            – Alex
                            yesterday

















                          This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

                          – Alex
                          yesterday





                          This should be the accepted answer: git-bash for Windows 7; Linux Subsystem available in Windows 10

                          – Alex
                          yesterday











                          0














                          If you are using cmder (or msysgit/mingw that has scp & ssh), I just wrote a simple python script for this. It can be found here: https://gist.github.com/ceilfors/fb6908dc8ac96e8fc983



                          Sample usage: python ssh-copy-id.py user@remote-machine.



                          Password will be prompted upon running the script.






                          share|improve this answer
























                          • why does this require cmder?

                            – David Zorychta
                            Jan 7 '16 at 3:39











                          • @user57411 It doesn't require cmder, it requires scp and ssh commands.

                            – ceilfors
                            Jan 7 '16 at 6:49
















                          0














                          If you are using cmder (or msysgit/mingw that has scp & ssh), I just wrote a simple python script for this. It can be found here: https://gist.github.com/ceilfors/fb6908dc8ac96e8fc983



                          Sample usage: python ssh-copy-id.py user@remote-machine.



                          Password will be prompted upon running the script.






                          share|improve this answer
























                          • why does this require cmder?

                            – David Zorychta
                            Jan 7 '16 at 3:39











                          • @user57411 It doesn't require cmder, it requires scp and ssh commands.

                            – ceilfors
                            Jan 7 '16 at 6:49














                          0












                          0








                          0







                          If you are using cmder (or msysgit/mingw that has scp & ssh), I just wrote a simple python script for this. It can be found here: https://gist.github.com/ceilfors/fb6908dc8ac96e8fc983



                          Sample usage: python ssh-copy-id.py user@remote-machine.



                          Password will be prompted upon running the script.






                          share|improve this answer













                          If you are using cmder (or msysgit/mingw that has scp & ssh), I just wrote a simple python script for this. It can be found here: https://gist.github.com/ceilfors/fb6908dc8ac96e8fc983



                          Sample usage: python ssh-copy-id.py user@remote-machine.



                          Password will be prompted upon running the script.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jul 3 '14 at 15:01









                          ceilforsceilfors

                          1092




                          1092













                          • why does this require cmder?

                            – David Zorychta
                            Jan 7 '16 at 3:39











                          • @user57411 It doesn't require cmder, it requires scp and ssh commands.

                            – ceilfors
                            Jan 7 '16 at 6:49



















                          • why does this require cmder?

                            – David Zorychta
                            Jan 7 '16 at 3:39











                          • @user57411 It doesn't require cmder, it requires scp and ssh commands.

                            – ceilfors
                            Jan 7 '16 at 6:49

















                          why does this require cmder?

                          – David Zorychta
                          Jan 7 '16 at 3:39





                          why does this require cmder?

                          – David Zorychta
                          Jan 7 '16 at 3:39













                          @user57411 It doesn't require cmder, it requires scp and ssh commands.

                          – ceilfors
                          Jan 7 '16 at 6:49





                          @user57411 It doesn't require cmder, it requires scp and ssh commands.

                          – ceilfors
                          Jan 7 '16 at 6:49











                          0














                          what i did, having CygWin on my Win10, connecting to Linux (based on aboves answer):



                          - note: using cat, it would resolve the cygwin path automatically, as well as any cygwin command using the cygwin-linux-folder-structure



                          1. added c:cygwinbin to the environment's Path variable
                          2. starting cmd.exe (windows commandline)
                          3. > ssh-keygen -t rsa (just pressing enter till done)
                          4. > cat ~/.ssh/id_rsa.pub | ssh user@server "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys"
                          5. ..enter server password
                          6. > ssh user@server (testing, not beeing asked for password)





                          share|improve this answer




























                            0














                            what i did, having CygWin on my Win10, connecting to Linux (based on aboves answer):



                            - note: using cat, it would resolve the cygwin path automatically, as well as any cygwin command using the cygwin-linux-folder-structure



                            1. added c:cygwinbin to the environment's Path variable
                            2. starting cmd.exe (windows commandline)
                            3. > ssh-keygen -t rsa (just pressing enter till done)
                            4. > cat ~/.ssh/id_rsa.pub | ssh user@server "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys"
                            5. ..enter server password
                            6. > ssh user@server (testing, not beeing asked for password)





                            share|improve this answer


























                              0












                              0








                              0







                              what i did, having CygWin on my Win10, connecting to Linux (based on aboves answer):



                              - note: using cat, it would resolve the cygwin path automatically, as well as any cygwin command using the cygwin-linux-folder-structure



                              1. added c:cygwinbin to the environment's Path variable
                              2. starting cmd.exe (windows commandline)
                              3. > ssh-keygen -t rsa (just pressing enter till done)
                              4. > cat ~/.ssh/id_rsa.pub | ssh user@server "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys"
                              5. ..enter server password
                              6. > ssh user@server (testing, not beeing asked for password)





                              share|improve this answer













                              what i did, having CygWin on my Win10, connecting to Linux (based on aboves answer):



                              - note: using cat, it would resolve the cygwin path automatically, as well as any cygwin command using the cygwin-linux-folder-structure



                              1. added c:cygwinbin to the environment's Path variable
                              2. starting cmd.exe (windows commandline)
                              3. > ssh-keygen -t rsa (just pressing enter till done)
                              4. > cat ~/.ssh/id_rsa.pub | ssh user@server "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys"
                              5. ..enter server password
                              6. > ssh user@server (testing, not beeing asked for password)






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Sep 6 '15 at 6:19









                              BananaAcidBananaAcid

                              1114




                              1114























                                  0














                                  This following steps would do:



                                  STEP-1: Generate RSA Key Pair



                                  C:Usersuser>ssh-keygen
                                  Generating public/private rsa key pair.
                                  Enter file in which to save the key (/c/Users/user//.ssh/id_rsa):
                                  Enter passphrase (empty for no passphrase):
                                  Enter same passphrase again:
                                  Your identification has been saved in /c/Users/user//.ssh/id_rsa.
                                  Your public key has been saved in /c/Users/user//.ssh/id_rsa.pub.
                                  The key fingerprint is:
                                  20:16:9b:0d:00:92:c4:34:99:51:20:b7:ef:50:c4:0f user@localhost


                                  STE2-2: ssh-copy-id equivalent in windows



                                  C:Usersuser>ssh user@remote "umask 077; test -d .ssh || mkdir .ssh ; cat >> .s
                                  sh/authorized_keys || exit 1" < "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys
                                  || exit 1" < C:Usersuser.sshid_rsa.pub
                                  The authenticity of host 'remote (xx.xx.xxx.xx)' can't be established.
                                  RSA key fingerprint is 99:99:73:74:fe:14:bc:91:c8:3b:ac:f4:95:99:4d:06.
                                  Are you sure you want to continue connecting (yes/no)? yes
                                  Warning: Permanently added 'remote,xx.xx.xxx.xx' (RSA) to the list of known hosts.
                                  *************************************************************************
                                  This computer system is the property of Sample Corporation and is to
                                  be used for business purposes. All information, messages, software and
                                  hardware created, stored, accessed, received, or used by you through
                                  this system is considered to be the sole property of Sample Corporation
                                  and can and may be monitored, reviewed, and retained at any time. You
                                  should have no expectation that any such information, messages or
                                  material will be private. By accessing and using this computer, you
                                  acknowledge and consent to such monitoring and information retrieval.
                                  By accessing and using this computer, you also agree to comply with
                                  all of Sample Company's policies and standards.
                                  *************************************************************************
                                  user@remote's password:[Enter Password for first time]


                                  STEP-3: Passwordless authentication works!



                                  C:Usersuser>ssh user@remote
                                  *************************************************************************
                                  This computer system is the property of Sample Corporation and is to
                                  be used for business purposes. All information, messages, software and
                                  hardware created, stored, accessed, received, or used by you through
                                  this system is considered to be the sole property of Sample Corporation
                                  and can and may be monitored, reviewed, and retained at any time. You
                                  should have no expectation that any such information, messages or
                                  material will be private. By accessing and using this computer, you
                                  acknowledge and consent to such monitoring and information retrieval.
                                  By accessing and using this computer, you also agree to comply with
                                  all of Sample Company's policies and standards.
                                  *************************************************************************
                                  Last login: Wed Oct 14 14:37:13 2015 from localhost





                                  share|improve this answer






























                                    0














                                    This following steps would do:



                                    STEP-1: Generate RSA Key Pair



                                    C:Usersuser>ssh-keygen
                                    Generating public/private rsa key pair.
                                    Enter file in which to save the key (/c/Users/user//.ssh/id_rsa):
                                    Enter passphrase (empty for no passphrase):
                                    Enter same passphrase again:
                                    Your identification has been saved in /c/Users/user//.ssh/id_rsa.
                                    Your public key has been saved in /c/Users/user//.ssh/id_rsa.pub.
                                    The key fingerprint is:
                                    20:16:9b:0d:00:92:c4:34:99:51:20:b7:ef:50:c4:0f user@localhost


                                    STE2-2: ssh-copy-id equivalent in windows



                                    C:Usersuser>ssh user@remote "umask 077; test -d .ssh || mkdir .ssh ; cat >> .s
                                    sh/authorized_keys || exit 1" < "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys
                                    || exit 1" < C:Usersuser.sshid_rsa.pub
                                    The authenticity of host 'remote (xx.xx.xxx.xx)' can't be established.
                                    RSA key fingerprint is 99:99:73:74:fe:14:bc:91:c8:3b:ac:f4:95:99:4d:06.
                                    Are you sure you want to continue connecting (yes/no)? yes
                                    Warning: Permanently added 'remote,xx.xx.xxx.xx' (RSA) to the list of known hosts.
                                    *************************************************************************
                                    This computer system is the property of Sample Corporation and is to
                                    be used for business purposes. All information, messages, software and
                                    hardware created, stored, accessed, received, or used by you through
                                    this system is considered to be the sole property of Sample Corporation
                                    and can and may be monitored, reviewed, and retained at any time. You
                                    should have no expectation that any such information, messages or
                                    material will be private. By accessing and using this computer, you
                                    acknowledge and consent to such monitoring and information retrieval.
                                    By accessing and using this computer, you also agree to comply with
                                    all of Sample Company's policies and standards.
                                    *************************************************************************
                                    user@remote's password:[Enter Password for first time]


                                    STEP-3: Passwordless authentication works!



                                    C:Usersuser>ssh user@remote
                                    *************************************************************************
                                    This computer system is the property of Sample Corporation and is to
                                    be used for business purposes. All information, messages, software and
                                    hardware created, stored, accessed, received, or used by you through
                                    this system is considered to be the sole property of Sample Corporation
                                    and can and may be monitored, reviewed, and retained at any time. You
                                    should have no expectation that any such information, messages or
                                    material will be private. By accessing and using this computer, you
                                    acknowledge and consent to such monitoring and information retrieval.
                                    By accessing and using this computer, you also agree to comply with
                                    all of Sample Company's policies and standards.
                                    *************************************************************************
                                    Last login: Wed Oct 14 14:37:13 2015 from localhost





                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      This following steps would do:



                                      STEP-1: Generate RSA Key Pair



                                      C:Usersuser>ssh-keygen
                                      Generating public/private rsa key pair.
                                      Enter file in which to save the key (/c/Users/user//.ssh/id_rsa):
                                      Enter passphrase (empty for no passphrase):
                                      Enter same passphrase again:
                                      Your identification has been saved in /c/Users/user//.ssh/id_rsa.
                                      Your public key has been saved in /c/Users/user//.ssh/id_rsa.pub.
                                      The key fingerprint is:
                                      20:16:9b:0d:00:92:c4:34:99:51:20:b7:ef:50:c4:0f user@localhost


                                      STE2-2: ssh-copy-id equivalent in windows



                                      C:Usersuser>ssh user@remote "umask 077; test -d .ssh || mkdir .ssh ; cat >> .s
                                      sh/authorized_keys || exit 1" < "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys
                                      || exit 1" < C:Usersuser.sshid_rsa.pub
                                      The authenticity of host 'remote (xx.xx.xxx.xx)' can't be established.
                                      RSA key fingerprint is 99:99:73:74:fe:14:bc:91:c8:3b:ac:f4:95:99:4d:06.
                                      Are you sure you want to continue connecting (yes/no)? yes
                                      Warning: Permanently added 'remote,xx.xx.xxx.xx' (RSA) to the list of known hosts.
                                      *************************************************************************
                                      This computer system is the property of Sample Corporation and is to
                                      be used for business purposes. All information, messages, software and
                                      hardware created, stored, accessed, received, or used by you through
                                      this system is considered to be the sole property of Sample Corporation
                                      and can and may be monitored, reviewed, and retained at any time. You
                                      should have no expectation that any such information, messages or
                                      material will be private. By accessing and using this computer, you
                                      acknowledge and consent to such monitoring and information retrieval.
                                      By accessing and using this computer, you also agree to comply with
                                      all of Sample Company's policies and standards.
                                      *************************************************************************
                                      user@remote's password:[Enter Password for first time]


                                      STEP-3: Passwordless authentication works!



                                      C:Usersuser>ssh user@remote
                                      *************************************************************************
                                      This computer system is the property of Sample Corporation and is to
                                      be used for business purposes. All information, messages, software and
                                      hardware created, stored, accessed, received, or used by you through
                                      this system is considered to be the sole property of Sample Corporation
                                      and can and may be monitored, reviewed, and retained at any time. You
                                      should have no expectation that any such information, messages or
                                      material will be private. By accessing and using this computer, you
                                      acknowledge and consent to such monitoring and information retrieval.
                                      By accessing and using this computer, you also agree to comply with
                                      all of Sample Company's policies and standards.
                                      *************************************************************************
                                      Last login: Wed Oct 14 14:37:13 2015 from localhost





                                      share|improve this answer















                                      This following steps would do:



                                      STEP-1: Generate RSA Key Pair



                                      C:Usersuser>ssh-keygen
                                      Generating public/private rsa key pair.
                                      Enter file in which to save the key (/c/Users/user//.ssh/id_rsa):
                                      Enter passphrase (empty for no passphrase):
                                      Enter same passphrase again:
                                      Your identification has been saved in /c/Users/user//.ssh/id_rsa.
                                      Your public key has been saved in /c/Users/user//.ssh/id_rsa.pub.
                                      The key fingerprint is:
                                      20:16:9b:0d:00:92:c4:34:99:51:20:b7:ef:50:c4:0f user@localhost


                                      STE2-2: ssh-copy-id equivalent in windows



                                      C:Usersuser>ssh user@remote "umask 077; test -d .ssh || mkdir .ssh ; cat >> .s
                                      sh/authorized_keys || exit 1" < "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys
                                      || exit 1" < C:Usersuser.sshid_rsa.pub
                                      The authenticity of host 'remote (xx.xx.xxx.xx)' can't be established.
                                      RSA key fingerprint is 99:99:73:74:fe:14:bc:91:c8:3b:ac:f4:95:99:4d:06.
                                      Are you sure you want to continue connecting (yes/no)? yes
                                      Warning: Permanently added 'remote,xx.xx.xxx.xx' (RSA) to the list of known hosts.
                                      *************************************************************************
                                      This computer system is the property of Sample Corporation and is to
                                      be used for business purposes. All information, messages, software and
                                      hardware created, stored, accessed, received, or used by you through
                                      this system is considered to be the sole property of Sample Corporation
                                      and can and may be monitored, reviewed, and retained at any time. You
                                      should have no expectation that any such information, messages or
                                      material will be private. By accessing and using this computer, you
                                      acknowledge and consent to such monitoring and information retrieval.
                                      By accessing and using this computer, you also agree to comply with
                                      all of Sample Company's policies and standards.
                                      *************************************************************************
                                      user@remote's password:[Enter Password for first time]


                                      STEP-3: Passwordless authentication works!



                                      C:Usersuser>ssh user@remote
                                      *************************************************************************
                                      This computer system is the property of Sample Corporation and is to
                                      be used for business purposes. All information, messages, software and
                                      hardware created, stored, accessed, received, or used by you through
                                      this system is considered to be the sole property of Sample Corporation
                                      and can and may be monitored, reviewed, and retained at any time. You
                                      should have no expectation that any such information, messages or
                                      material will be private. By accessing and using this computer, you
                                      acknowledge and consent to such monitoring and information retrieval.
                                      By accessing and using this computer, you also agree to comply with
                                      all of Sample Company's policies and standards.
                                      *************************************************************************
                                      Last login: Wed Oct 14 14:37:13 2015 from localhost






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Oct 15 '15 at 19:40









                                      kasperd

                                      26.8k1252104




                                      26.8k1252104










                                      answered Oct 15 '15 at 18:59









                                      GANESHGANESH

                                      1




                                      1























                                          0














                                          There is a Windows version of ssh-copy-id I found on GitHub:
                                          https://github.com/zhengyi-yang/ssh-copy-id/tree/master/dist






                                          share|improve this answer




























                                            0














                                            There is a Windows version of ssh-copy-id I found on GitHub:
                                            https://github.com/zhengyi-yang/ssh-copy-id/tree/master/dist






                                            share|improve this answer


























                                              0












                                              0








                                              0







                                              There is a Windows version of ssh-copy-id I found on GitHub:
                                              https://github.com/zhengyi-yang/ssh-copy-id/tree/master/dist






                                              share|improve this answer













                                              There is a Windows version of ssh-copy-id I found on GitHub:
                                              https://github.com/zhengyi-yang/ssh-copy-id/tree/master/dist







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Jan 7 '17 at 12:45









                                              user393933user393933

                                              91




                                              91























                                                  0














                                                  Powershell version for SSH included in Git For Windows



                                                  In fact, it can work as long as you have ssh in your path.
                                                  Add the following in your powershell profile:



                                                  function ssh-copy-id([string]$userAtMachine){   
                                                  $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
                                                  if (!(Test-Path "$publicKey")){
                                                  Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
                                                  }
                                                  else {
                                                  & cat "$publicKey" | ssh $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
                                                  }
                                                  }


                                                  In a powershell console:



                                                  ssh-copy-id user@machine





                                                  share|improve this answer


























                                                  • ssh-copy-id is not supposed to generate a key if it doesn't exist.

                                                    – RalfFriedl
                                                    Dec 9 '18 at 12:05











                                                  • @RalfFriedl I removed the keygen

                                                    – Fab
                                                    Dec 11 '18 at 14:26
















                                                  0














                                                  Powershell version for SSH included in Git For Windows



                                                  In fact, it can work as long as you have ssh in your path.
                                                  Add the following in your powershell profile:



                                                  function ssh-copy-id([string]$userAtMachine){   
                                                  $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
                                                  if (!(Test-Path "$publicKey")){
                                                  Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
                                                  }
                                                  else {
                                                  & cat "$publicKey" | ssh $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
                                                  }
                                                  }


                                                  In a powershell console:



                                                  ssh-copy-id user@machine





                                                  share|improve this answer


























                                                  • ssh-copy-id is not supposed to generate a key if it doesn't exist.

                                                    – RalfFriedl
                                                    Dec 9 '18 at 12:05











                                                  • @RalfFriedl I removed the keygen

                                                    – Fab
                                                    Dec 11 '18 at 14:26














                                                  0












                                                  0








                                                  0







                                                  Powershell version for SSH included in Git For Windows



                                                  In fact, it can work as long as you have ssh in your path.
                                                  Add the following in your powershell profile:



                                                  function ssh-copy-id([string]$userAtMachine){   
                                                  $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
                                                  if (!(Test-Path "$publicKey")){
                                                  Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
                                                  }
                                                  else {
                                                  & cat "$publicKey" | ssh $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
                                                  }
                                                  }


                                                  In a powershell console:



                                                  ssh-copy-id user@machine





                                                  share|improve this answer















                                                  Powershell version for SSH included in Git For Windows



                                                  In fact, it can work as long as you have ssh in your path.
                                                  Add the following in your powershell profile:



                                                  function ssh-copy-id([string]$userAtMachine){   
                                                  $publicKey = "$ENV:USERPROFILE" + "/.ssh/id_rsa.pub"
                                                  if (!(Test-Path "$publicKey")){
                                                  Write-Error "ERROR: failed to open ID file '$publicKey': No such file"
                                                  }
                                                  else {
                                                  & cat "$publicKey" | ssh $userAtMachine "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1"
                                                  }
                                                  }


                                                  In a powershell console:



                                                  ssh-copy-id user@machine






                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Dec 11 '18 at 14:25

























                                                  answered Dec 9 '18 at 10:44









                                                  FabFab

                                                  1014




                                                  1014













                                                  • ssh-copy-id is not supposed to generate a key if it doesn't exist.

                                                    – RalfFriedl
                                                    Dec 9 '18 at 12:05











                                                  • @RalfFriedl I removed the keygen

                                                    – Fab
                                                    Dec 11 '18 at 14:26



















                                                  • ssh-copy-id is not supposed to generate a key if it doesn't exist.

                                                    – RalfFriedl
                                                    Dec 9 '18 at 12:05











                                                  • @RalfFriedl I removed the keygen

                                                    – Fab
                                                    Dec 11 '18 at 14:26

















                                                  ssh-copy-id is not supposed to generate a key if it doesn't exist.

                                                  – RalfFriedl
                                                  Dec 9 '18 at 12:05





                                                  ssh-copy-id is not supposed to generate a key if it doesn't exist.

                                                  – RalfFriedl
                                                  Dec 9 '18 at 12:05













                                                  @RalfFriedl I removed the keygen

                                                  – Fab
                                                  Dec 11 '18 at 14:26





                                                  @RalfFriedl I removed the keygen

                                                  – Fab
                                                  Dec 11 '18 at 14:26


















                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Server Fault!


                                                  • 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%2fserverfault.com%2fquestions%2f224810%2fis-there-an-equivalent-to-ssh-copy-id-for-windows%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

                                                  As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

                                                  Список ссавців Італії Природоохоронні статуси | Список |...

                                                  Українські прізвища Зміст Історичні відомості |...