[Mac Tip] Quickly Copy Files from Local to Remote Machine through SSH

By ET

Note the beautiful title bars you see in this blog.


They are on top of the blog, each time you reload the page, you get a different title bar.

I may write a post about these title bars and the stories behind them later, but today, I’d like to record how I can copy them quickly to the title bar directory from my Mac.

There are a few steps:

  1. Create publickey authentication on the remote server, in this case: mikezhang.com
    • Type “ssh-keygen -d” on the local server
    • Then, typ “ssh -l username mikezhang.com ‘test -d .ssh || mkdir -m 0700 .ssh ; cat >> .ssh/authorized_keys && chmod 0600 .ssh/*’ < ~/.ssh/id_dsa.pub”, this creates a new directory on the remote server called .ssh and paste the public key into the file “authorized_keys”
    • Make sure the .ssh created on the remote server is chmod to 0700
    • test if we can directly go there by “ssh -l username mikezhang.com” without typing the password
  2. Create a new directory on the local machine:
    • and a new file at ~/Library/Application Support/Quicksilver/Actions/Copy To Server.sh
    • the content of the file will be
      #!/bin/sh
      #
      infile=`echo $1|tr '"' '\"'`;
      filename=`basename "$infile"`;
      `/usr/bin/scp "$infile" username@mikezhang.com:/home/username/mikezhang.com/wp-content/themes/aura/headerimg/`;
      base="http://mikezhang.com/wp-content/themes/aura/headerimg/";
      echo "$base$filename" | perl -ne 's/ /%20/g; print';

  3. That’s all

To use the shortcut, select the newly created title bars, invoke QS, type “Current Selection..”, then “TAB”, then “Copy to”, the option called “Copy to Server” will show up, press Enter. It’s done.

Here is the newest addition:

Leave a Reply


BlogTimer
You are visitor number several since September 1, 2001

Copyright Xiaoquan (Michael) Zhang, 2004-2007. All rights reserved.
All trademarks property of their owners.