I have two Macs which is MBP and iMac.
Since I need to synchronize files in both Macs,
I was finding out several candidates of synchronization applications.
Among them, the ChronoSync which is developed by Econ technology was the best
for me. It gives me that folder to folder sync, schedule sync and several
options.
However, the problem is transmission speed.
In my case, the ChronoSync syncs my files at a snail pace.
I don't know why.
So, I tried to find out another sync applications for Mac.
And my friend taught me one which is terminal command based sync program named
"rsync".
rsync can synchronize files between any folders in your Mac,
even it does in remotely connected mac which is possible to connect with ssh.
In my case, there is one more problem that I usually use my MBP in my univ. and iMac is at my home.
And thus, I need to connect two macs with ssh but
my Univ. does NOT allow any ssh connections from external requests.
Fortunately, however, I can connect my MBP in my univ. from iMac in my home with iCloud.
And there is a solution to use ssh with iCloud.
Setting Back to My Mac
Open System Preferences, go to iCloud and Check Back to My Mac.
How to Connect SSH with iCloud
First, find out your iCloud ID.
Open terminal and type
dns-sd -E
then, you can obtain your 9-digits iCloud ID.
After obtaining iCloud ID, you can now connect to remote Macs with SSH through iCloud.
The method is simple.
Type below command to the terminal.
ssh -2 -6 account@remotemac.yourid.members.btmm.icloud.com
You have to change to your appropriate parameter written in italic as below :
yourid : your 9-digits iCloud ID
remotemac : target system name what you want to connect to
account : your account name of remotemac
This is very long command to type in the terminal.
SSH supports, however, shrinking paths.
Type below command in the terminal
vi ~/.ssh/config
Then press i (if you don't know how to use vi) to enter edit mode, and type below stuffs (in my case I set user as quezina)
Host remote-ssh
User quezina
HostName remotemac.yourid.members.btmm.icloud.com
AddressFamily inet6
Protocol 2
Note that letters written italic should be changed for your case.
Then save it and quit. (in ordet to save and quit in vi, you should press Esc key and type :wq and return key)
You can now connect to remotemac with SSH through iCloud.
Check your setting in terminal by typing below command
ssh remote-ssh
[Tips] you have to enter you password of remotemac every time when you connect to.
But, you can omit this process by generating public key.
please refer to this site : Setting up SSH public/private keys
How to Use rsync with SSH through iCloud
Almost done if you succeeded connecting SSH through iCloud.
rsync supports synchronization with SSH.
If you want to sync between (in you mac)
/home/source/
and (in remotemac)
/storage/source/
then, just open the terminal and type below command
rsync -avPz --delete --stats -l -t -e ssh /home/source/ remote-ssh:/storage/source
Note that there is backslash at the end of your mac's path (/home/source/) but destination (remotemac) does NOT have it.
This gives us quiet different results whether '/' is or not.
rsync description explains difference as follows:
This gives us quiet different results whether '/' is or not.
rsync description explains difference as follows:
rsync -avz foo:src/bar/ /data/tmp
A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:
rsync -av /src/foo /dest rsync -av /src/foo/ /dest/foo
That's all.










0 개의 댓글:
댓글 쓰기