How to sudo over scp

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.,

1.) scp the file to a remote location
2.) copy the file to destination location via sudo and ssh

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.

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:

ssh remoteserver.com sudo sh -c '"cat > /root/file"' < /my_source_file

This computer problem is easy and piece of cake.

--Derrick

Our sponsors:

HP2009m: Power Button Lockout

When I tried to turn off my HP2009m monitor by pushing the power button, I see the following message:

Power Button Lockout

Since HP has a tradition to make beautiful and quality monitor with the worst power button (Which means you have to keep it power on, or you need to get a new one even the monitor is doing okay), I was worrying about whether my monitor is “dead” or not.

After unplugging the power cable for a night and put it back the next day, I found that the problem was still there. So, finally I decided to reset the monitor to factory settings. Yay! It works!

So here is what I’ve done:

  • Push the Menu button
  • Select Factory Reset using the +/- key
  • Push the OK button
  • Select Yes by using the +/- key
  • Push the OK button

This computer problem should be gone. If the computer problem still exists, I will take apart the monitor (by remove the frame) and re-adjust the power button. That’s how I save my another HP monitor from being sent to landfill.

–Derrick

Our sponsors: