Setting up SSH access on Windows
In Windows, after installing Drush through the installer, some extra configuration is needed in order to execute commands in remote systems or synchronize data.
First of all, unless you are sure that when you installed Drush you marked the components "cwRsync" and "Register Environment Variables", launch the Drush installer again, click on Change and install them. This will set up your PATH variable with the location of every program that Drush needs and install cwRsync in order to use the Drush command core-rsync.
That being done, you will have to create your home path where cwRsync has been installed. this directory will be used to store your SSH key. Follow these steps to generate your SSH key and copy it to the remote host:
- Open the command line interpreter by going to Start > Execute > type cmd and hit Enter.
- Go to the cwRsync installation directory:
cd C:\Program Files\Propeople\Drush\cwRsync - Create your home directory at this level. It should be "home/your Windows username". If you type your username wrong, you will get an error later on when we execute a command for a remote Drupal site which will let you know how should the folder under home be called.
mkdir home
cd home
Useful Unix/Linux Commands for Drupal
Following are some useful Unix/Linux commands which are helpful if you are dealing with large sites (files and db size). I find these really handy when moving sites from one server to other, taking backups of Files, Database etc.
Note: To get access to the Unix command line, you will need an SSH client (e.g. Putty). You can also use WinSCP if you are not comfortable with Command line. WinSCP has a feature to enter custom commands using its interface.
Please add other command-line commands that you use while setting up, developing and managing your Drupal sites.
Zip Contents of current directoryzip -r zipfile.zip *
Unzip Contents into current directoryunzip zipfile.zip
Unzip (and extract) the tar'd, gzipped archive (tarball) Contents into current directorytar zxvf tarballfile.tar.gz
Remove a directory and its contents (Use with extra care)rm -rf directoryname
Backup Databasemysqldump dbname -uUSERNAME -pPASSWORD --host HOST > filename.sql
Restore Databasemysql -u root -p[root_password] [database_name] < dumpfilename.sql
Copy all files / directories from one server to other (Both servers should have SSH Support)rsync -avz --progress username@servername:sourcefolder destinationfolder
Generate and upload SSH keys to Drupal from Git
This is a simple method to create, upload and verify an SSH Key with Drupal.org
Generate a key for the first time
Open the Git Bash window and change to the .ssh directory
cd ~/.sshIf the .ssh directory does not exist, change to the user directory then create the .ssh directory and enter it.
cd ~
mkdir .ssh
cd .sshNOTE: Do not include any spaces in your keyname as it can cause problem when you upload your public key to some sites.
At the Git Bash prompt, enter:
ssh-keygen -t rsa (optional " -C keyname" where keyname is anything you want)You should see:
Generating public/private rsa key pair.
Enter file in which to save the key (/u/.ssh/id_rsa):Press 'Enter' here to accept the default
Enter passphrase (empty for no passphrase):
Enter same passphrase again:Press enter to leave the passphrase empty.
Your identification has been saved in /u/.ssh/id_rsa.
Your public key has been saved in /u/.ssh/id_rsa.pub.
The key fingerprint is:
7e:f5:7e:51:ec:3d:2c:36:02:9d:5b:89:4a:3a:b7:b5 keynameCopy your Key
At the Git Bash prompt, type:
cat .ssh/id_rsa.pubYou should see something like:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq/9IAUH