{"id":4599,"date":"2018-01-09T07:36:40","date_gmt":"2018-01-09T07:36:40","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=4599"},"modified":"2018-09-25T10:16:19","modified_gmt":"2018-09-25T10:16:19","slug":"how-to-scp-ssh-and-rsync-without-prompting-for-password-using-openssh","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-scp-ssh-and-rsync-without-prompting-for-password-using-openssh\/","title":{"rendered":"How To scp, ssh and rsync without prompting for password using OpenSSH"},"content":{"rendered":"<p><strong>Verify that local-host and remote-host is running openSSH<\/strong><br \/>\n<em>ssh -V<\/em><br \/>\n<em>OpenSSH_4.3p2, OpenSSL 0.9.8b 04 May 2006<\/em><\/p>\n<p><strong>Lets say you want to copy between two hosts host_src and host_dest. host_src is the host where you would run the scp, ssh or rsyn command, irrespective of the direction of the file copy!<\/strong><br \/>\n<strong>1.<\/strong>\u00a0On host_src, run this command as the user that runs scp\/ssh\/rsync<br \/>\n$ ssh-keygen -t rsa<br \/>\nThis will prompt for a passphrase. Just press the enter key. It&#8217;ll then generate an identification (private key) and a public key. Do not ever share the private key with anyone! ssh-keygen shows where it saved the public key. This is by default ~\/.ssh\/id_rsa.pub:<br \/>\nYour public key has been saved in &lt;your_home_dir&gt;\/.ssh\/id_rsa.pub<\/p>\n<p><strong>2.<\/strong>\u00a0Transfer the id_rsa.pub file to host_dest by either ftp, scp, rsync or any other method.<\/p>\n<p><strong>3.<\/strong>\u00a0On host_dest, login as the remote user which you plan to use when you run scp, ssh or rsync on host_src.<\/p>\n<p><strong>4.<\/strong>\u00a0Copy the contents of id_rsa.pub to ~\/.ssh\/authorized_keys<br \/>\n$ cat id_rsa.pub &gt;&gt;~\/.ssh\/authorized_keys<br \/>\n$ chmod 700 ~\/.ssh\/authorized_keys<br \/>\nIf this file does not exists, then the above command will create it. Make sure you remove permission for others to read this file. If its a public key, why prevent others from reading this file? Probably, the owner of the key has distributed it to a few trusted users and has not placed any additional security measures to check if its really a trusted user.<\/p>\n<p><strong>5.<\/strong>\u00a0Note that ssh by default does not allow root to log in. This has to be explicitly enabled on host_dest. This can be done by editing \/etc\/ssh\/sshd_config and changing the option of PermitRootLogin from no to yes. Don&#8217;t forget to restart sshd so that it reads the modified config file. Do this only if you want to use the root login.<\/p>\n<p><strong>Putty using Windows:<\/strong><\/p>\n<p>If you are trying using windows, you can use puttygen to generate public\/private keys and do the configuration in putty as in image below to connect to other server&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p>PIC TO BE UPLOADED&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Reference.<\/strong><br \/>\n<a href=\"http:\/\/www.thegeekstuff.com\/2008\/10\/perform-ssh-and-scp-without-password-from-ssh2-to-openssh\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.thegeekstuff.com\/2008\/10\/perform-ssh-and-scp-without-password-from-ssh2-to-openssh\/<\/a><br \/>\n<a href=\"http:\/\/blogs.oracle.com\/jkini\/entry\/how_to_scp_scp_and\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/blogs.oracle.com\/jkini\/entry\/how_to_scp_scp_and<\/a><br \/>\n<a href=\"http:\/\/www.thegeekstuff.com\/2008\/06\/perform-ssh-and-scp-without-entering-password-on-openssh\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.thegeekstuff.com\/2008\/06\/perform-ssh-and-scp-without-entering-password-on-openssh\/<\/a><br \/>\n<a href=\"http:\/\/www.csua.berkeley.edu\/~ranga\/notes\/ssh_nopass.html\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.csua.berkeley.edu\/~ranga\/notes\/ssh_nopass.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Verify that local-host and remote-host is running openSSH ssh -V OpenSSH_4.3p2, OpenSSL 0.9.8b 04 May 2006 Lets say you want to copy between two hosts host_src and host_dest. host_src is&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4957],"tags":[4521,534,566,4520,896],"class_list":["post-4599","post","type-post","status-publish","format-standard","hentry","category-linux","tag-openssh","tag-password","tag-rsync","tag-scp","tag-ssh"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=4599"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4599\/revisions"}],"predecessor-version":[{"id":4600,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4599\/revisions\/4600"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=4599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=4599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=4599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}