{"id":1173,"date":"2010-12-08T21:53:48","date_gmt":"2010-12-09T03:53:48","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=1173"},"modified":"2012-08-14T18:10:04","modified_gmt":"2012-08-14T23:10:04","slug":"how-to-sudo-over-scp","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/how-to-sudo-over-scp\/","title":{"rendered":"How to sudo over scp"},"content":{"rendered":"<p>Today, I like to copy a file from a server to a different server using command line in Unix. Since I like to put the file at a location that require root permission, if I do it using scp, I have to split it into two commands, i.e.,<\/p>\n<p>1.) scp the file to a remote location<br \/>\n2.) copy the file to destination location via sudo and ssh<\/p>\n<p>However, I like to do it in one single command. After trial and error for few times, finally I come up with a solution to solve this computer server problem.<\/p>\n<p>Suppose I want to copy a file from local server:\/my_source_file to remoteserver.com:\/root\/file, I can simply do everything in one single command:<\/p>\n<pre>\r\nssh remoteserver.com sudo sh -c '\"cat > \/root\/file\"' < \/my_source_file\r\n<\/pre>\n<p>This computer problem is easy and piece of cake.<\/p>\n<p>--Derrick<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, I like to copy a file from a server to a different server using command line in Unix. Since I like to put the file at a location that <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/how-to-sudo-over-scp\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[94,144,6,69],"tags":[103,102,104],"class_list":["post-1173","post","type-post","status-publish","format-standard","hentry","category-computer-problems-computer-help-pc-support","category-sever-problem","category-technology","category-troubleshooting-technology","tag-ssh","tag-sudo","tag-unix"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-iV","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3318,"url":"https:\/\/icesquare.com\/wordpress\/how-to-improve-rsync-performance\/","url_meta":{"origin":1173,"position":0},"title":"How to Improve rsync Performance","author":"Derrick","date":"October 8, 2013","format":false,"excerpt":"I need to transfer 10TB of data from one machine to another machine. Those 10TB of files are living in a large RAID which span across 7 different disks. The target machine has another large RAID which span across 12 different disks. It is not easy to copying those files\u2026","rel":"","context":"In &quot;FreeBSD&quot;","block_context":{"text":"FreeBSD","link":"https:\/\/icesquare.com\/wordpress\/category\/sever-problem\/freebsd\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1811,"url":"https:\/\/icesquare.com\/wordpress\/how-to-setup-tftp-on-ubuntu\/","url_meta":{"origin":1173,"position":1},"title":"How to Setup TFTP on Ubuntu 11.10","author":"Derrick","date":"November 23, 2011","format":false,"excerpt":"Recently I decide to jump into the pool of using diskless Ubuntu. Basically the client computer downloads the necessary files from the Ubuntu server every time during the boot. To keep things simple and easy, Ubuntu does that by using TFTP. So the first step is to set up a\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1067,"url":"https:\/\/icesquare.com\/wordpress\/package-ssh-is-not-available-but-is-referred-to-by-another-package-this-may-mean-that-the-package-is-missing-has-been-obsoleted-or-is-only-available-from-another-source\/","url_meta":{"origin":1173,"position":2},"title":"Package ssh is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source","author":"Derrick","date":"November 14, 2010","format":false,"excerpt":"Today, I helped my friend to install Debian. It was done via two GUI remote desktop connections (i.e., slow), and therefore I would like to access the server via SSH. So I tried to install the SSH package: sudo apt-get install -y ssh and I received the following message: Reading\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3309,"url":"https:\/\/icesquare.com\/wordpress\/sftp-without-ssh-shell-access-2\/","url_meta":{"origin":1173,"position":3},"title":"SFTP Without SSH Shell Access","author":"Derrick","date":"October 7, 2013","format":false,"excerpt":"I got an interesting question today. Our client needs to access to the server via SFTP, but they want to disable to the access to the SSH shell. Assuming that you are fully aware of the potential issues of doing it, such ask security risk etc, here is how to\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3489,"url":"https:\/\/icesquare.com\/wordpress\/install-usrports-doc-inappropriate-file-type-or-format\/","url_meta":{"origin":1173,"position":4},"title":"install: \/usr\/ports\/&#8230;\/doc\/: Inappropriate file type or format","author":"Derrick","date":"March 5, 2014","format":false,"excerpt":"While I tried to upgrade both of my FreeBSD server (9 & 10) today, I got the following error: install: \/usr\/ports\/...\/doc\/: Inappropriate file type or format Actually, here is the complete error message: ===> Staging for memcached-1.4.17_1 ===> memcached-1.4.17_1 depends on shared library: libevent-2.0.so - found ===> Generating temporary packing\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2036,"url":"https:\/\/icesquare.com\/wordpress\/solvedtftp-error-code-2-access-violation\/","url_meta":{"origin":1173,"position":5},"title":"[Solved]TFTP: Error code 2: Access violation","author":"Derrick","date":"December 13, 2011","format":false,"excerpt":"This post is an extension of my original post on TFTP: How to Setup TFTP. Although the post was written for Ubuntu, the same idea can be applied to all systems. So, here is our problem. You set up a TFTP server. It starts fine. You upload a file, it\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/11\/TFTP_Small.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/1173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1173"}],"version-history":[{"count":10,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/1173\/revisions"}],"predecessor-version":[{"id":2881,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/1173\/revisions\/2881"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}