Archive for ‘ssh’ Category
ssh »

Copying large number of files between two Unix/Linux/OSX Servers

datePosted on 14:38, August 15th, 2012 by Many Ayromlou

Here are some quick tip(s) for copying a ton of files between unixy machines really fast. You’re probably thinking “why not use rsync?”…..well rsync can be miserably slow if your source or destination cpu is underpowered. You can always do a rsync after these commands to make 100% certain that everything checks out, but try using one of these methods for the initial copy:

  • One way of doing it is
    tar -c /path/to/dir | ssh user@remote_server 'tar -xpvf - -C /absolute/path/to/remotedir'

    You’ll be prompted for the remote servers password or you can use the private key of the remote server using the -i switch in the ssh command. This has the side benefit of preserving permissions. An alternate version of this command can also be used to locally move folder structures across mount points while preserving permissions: 

    tar -cf - -C srcdir . | tar -xpf - -C destdir


    cd srcdir ; tar -cf - . | (cd destdir ; tar -xpf -)
  • Another way of doing it with netcat (nc) is
    srv1$ tar -cfv - * | nc -w1 4321

    followed by

    srv2$ nc -l -p 4321 |tar -xpfv - 

    Note that you type the first command on the source machine and the second command on the destination machine.

  • Yet another way of doing it with socat utility is
    host1$ tar -cvf - * | socat stdin tcp4:host2:portnum

    followed by

    host2$ socat tcp4-listen:portnum stdout | tar -xvpf - 

    Note that you type the first command on the source machine and the second command on the destination machine.

Once your favourite process (above) is done you can do a quick rsync to tie up any loose ends.

rsync -avW -e ssh /path/to/dir/ remote_server:/path/to/remotedir

Rsync will now fly through the filesystem as 99.9% of the time, 99.9% of the files on the destination are good. And as always make sure you understand the commands before you use them…..and keep backups just in case :-).

SSH to your remote machine using Back to My Mac iCloud Service

datePosted on 14:14, July 27th, 2012 by Many Ayromlou

This is kinda cool. It only works if you have access to “Back to My Mac” service and you have it turned on in the remote mac’s preferences (under iCloud preferences). If you ever need to find out the FQDN (Fully Qualified Domain Name) of your remote mac and connect to it via ssh or something like it you can use the following command in the terminal:

echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p'

This should spit out the “domain name” for your “personal” iCloud DNS. The output looks something like this:

To use this in a ssh command you would need the name of the remote machine plus the information above:

ssh -2 -6

That’s it… should see a prompt for ssh login to your remote machine.

The Ultimate File Transfer Utility for Windows

datePosted on 12:18, August 27th, 2010 by Many Ayromlou

I’ve been posting mainly about OSX for the last little while, but no worries, I haven’t given up on Windows…yet :-). Someone today was asking about a good WebDAV client and after searching around for a bit, it seems like there is really only a couple out there. But really none of them can beat BitKinex client in terms of features and “price”. Here is a short list of features (oh…and the price thing….it’s free:-) ):

  • Site Navigation Without Freezing Windows
    Unique technology of advanced directory caching and multi connection/threaded directory scanning makes the non-blocking browse windows possible.
  • Robust User Request Handling
    Resume and control in detail not only file transfers but all user requests – including file removals, moves, directory creations, remote edits, prints, etc.
  • Indirect Transfers
    Allows users to transfer files from one server to another regardless of which protocol they are running (FTP->SFTP, WebDAV->FTPS, HTTP->FTP, etc.)
  • Smart Messenger-like User Interface
    Does not occupy much space on your desktop.
  • Properties Inheritance
    For easy and flexible configuration.
  • Large Number of Supported Protocols
    Including FTP, FXP, FTPS, SFTP, HTTP, HTPS and WebDAV

I don’t know how they do it, but I would just grab a copy, if I were you :-).

SSH Tunneling to mysql server using Putty

datePosted on 12:55, September 25th, 2008 by Many Ayromlou

 I’ve had this question a couple of times in the past few months (since I posted the command line version of this method here ). To make it short and sweet, yes you can use Putty in a windows environment to setup ssh tunnels. Here is the specific scenario with pics for setting up a tunnel to your mysql server (assuming mysql server is running on a machine that you have ssh access to) using putty. This allows you to run mysql-gui-tools under windows and connect thru ssh to your server, without having to open the server to accept connections from the network.

  1. Download Putty full install package 
  2. Run putty and your’ll see the following screen. Fill in the hostname of the DB server and choose SSH as protocol.
  3. Go down to SSH and Tunnels options. Fill in 3306 for Source port, for local Destination port and click Add. This will forward (through SSH) all traffic sent to (aka. localhost:3306) to the remote host’s (DB Server) port 3306. You’ll see how this works in a second.
  4. Now go back to Sessions, Give the session a meaningful name (eg: MYSQLTunnel) and click Save so that it’s saved.

So now you’re done. If you need to access your mysql server, first run putty, load the session we just saved, connect and you’re good to go. You can use any network based mysql frontend and even the ODBC connector under windows and point them at host: and port: 3306, the SSH tunnel will then take the traffic and safely transfer it to your mysql server box. This way you can run your mysql server in local mode — where it will not accept connections from outside network — for safety reasons and have network access to it when you need.

Tunnel to locally running mysql server using ssh

datePosted on 12:35, June 17th, 2008 by Many Ayromlou

Running and administrating mysql can sometimes be a hassle especially if you’re running a semi-secure environment. This usually means that your mysql server will not accept connections from outside and only localhost connections are allowed. There is a quick way of getting around this if you’re stuck somewhere and really need to use that graphical admin/browser tool to get to your DB server. All you really need to do is forward port 3306 on your local machine to port 3306 on the DB server through a ssh tunnel. Here is the ssh command you need to issue to start things up:
ssh -L 3306:
Once you supply the password for the ssh session you’re in business, the encrypted tunnel is up and running. All you need now is to point Mysql Administrator graphical tool at host (localhost) and port 3306 like the picture below:The only thing you want to make sure you get right is the, DO NOT use localhost. The tools you’re using automatically assume a local socket connection to the DB when you use “localhost” as the Server Hostname. Another thing is that all checks that mysql administrator does locally on the server files will not work (ie: the interface will report that the server is down since it can’t find, but all users/schema manipulation works fine since they are network based.

If you have mysql daemon installed on your local machine (the machine you initiated ssh from) you need to change the local port to something else other than 3306 and the command will look something like this:
ssh -L 7777:
In this case I’m using local port 7777 which means I also have to tell mysql administrator to connect through port 7777. You get the idea……