Showing posts with label cygwin. Show all posts
Showing posts with label cygwin. Show all posts

Monday, February 4, 2008

Auto ssh login from Cygwin to linux server

I have a ssh2 client software installed before the installation of cygwin, but I never tried the auto login by public key successfully, one reason, I guess, is that my remote server doesn't have SSH2 server installed. Now that I am using cygwin, i install the openssh (not openssl) module from cygwin installation packages.

[cygwin:~/] ssh-keygen -t rsa (leave passphrase empty to make ssh-login easier)
[cygwin:~/] cd .ssh
[cygwin:~/] scp id_rsa.pub username@remote_host:.ssh/ (enter password this time)
[cygwin:~/] ssh username@remote_host (enter password this time)
[remote_host:~/] cd .ssh (create one if not existed)
[remote_host:~/] touch authorized_keys (create this file is not existed)
[remote_host:~/] cat id_rsa.pub >> authorized_keys
[remote_host:~/] rm -f id_rsa.pub
[remote_host:~/] chmod 600 authorized_keys
[remote_host:~/] cd ..
[remote_host:~/] chmod 700 .ssh
[remote_host:~/] exit
[cygwin:~/] ssh username@remote_host
[========== no password anymore, also for scp ===========]

Saturday, February 2, 2008

Run Ruby, Gems, Rails, MySQL and RMagick on Cygwin

Before using cygwin, I did not expect that the commands of rails do not work in cygwin. To make ruby, gems and rails to work, there are some additional tasks to do as following:

  • Add devel -> make + ruby + gcc + subversion modules from cygwin installation
  • Download gems tgz install package from Ruby Gems download home
  • tar xzvf rubygems-1.0.x.tgz
  • cd rubygems-1.0.x
  • unset RUBYOPT (before install gems, clear RUBYOPT=rubygems)
  • ruby setup.rb
  • gem install rails --include-dependencies
  • Download mysql source tar.gz file from MySQL download page
  • tar xzvf mysql-5.0.45.tar.gz
  • cd mysql-5.0.45
  • ./configure
  • make install ( or to do it faster, just make install under sub directories libmysql and include.
  • gem install mysql
  • Change the database server from localhost to 127.0.0.1 in the database.yml of your rails app
  • Install ImageMagick, libmagick-devel, XFree86-lib-compat, xorg-x11-devel, libbz2-devel module from cygwin installation file
  • gem install RMagick
  • ruby script/server. voila!

References:

Labnotes: Setting up Ruby + Gems on Cygwin
Softpedia: Install Rails on Windows with cygwin

Vim of Cygwin to Set default file format

If create a bash file under cygwin using vim, the default configuration of vim stores the bash file in the format of dos, therefore the bash file can not execute correctly.

To store the currently editting file in the format of unix:

:set fileformat (or ff)=unix

If I want to change the default file format of vim to unix, add this code into the .vimrc and .gvimrc file under my home directory:

set fileformats=unix,dos

Thursday, January 31, 2008

Install Cygwin, Linux Commands and GVim with Windows Vista

  • Download the "setup.exe" program from Cygwin (http://www.cygwin.com/setup.exe) then install it.
  • At the time of installing cygwin, select modules to install as you wish, such as cron, zip, unzip, shutdown, wget, openssh, perl.
  • Download the self-installing-on-windows executable GVim program from vim online (ftp://ftp.vim.org/pub/vim/pc/gvim71.exe) then install it.
  • Put vim installation path into the windows environment variable "PATH".
  • To set the colorscheme of GVim, create a .gvimrc file into home directory, say c:\Users\your_user_name\ with a line "colorscheme your_scheme", my favorite is murphy.
  • Open cygwin program, click "Properties" on the left top menu to set cygwin with your favorite color scheme and font.
  • To improve bash of cygwin, put a .bashrc file into home directory, but there are two tricks. Firstly cygwin may somehow ignore the .bashrc (I don't know why), the solution to this problem is to put an executable string in the bottom of /etc/profile:
. "$HOME/.bashrc"
  • Secondly if the format of .bashrc is pc not unix, this file may not be executed correctly. I use EditPlus to transfer the format to unix.
  • My .bashrc file is like this:
##################################################
# .bashrc file
##################################################
# PATH
#=================================================
# Add "." and "~/bin" to PATH varible:
# export PATH=.:/home/user_name/bin:`printenv PATH`

# Aliases
#=================================================
alias more=less
alias up='cd ..'
alias ll='ls -la'
alias ls='ls -F'
alias ps='ps -Wl'
alias home='cd $HOME'
alias which='type -path'
alias unix2dos='recode lat1:ibmpc'
alias dos2unix='recode ibmpc:lat1'
alias h='history 30'
alias rmf='rm -Rf'
alias v='vim'
alias su='su -'
alias tails='tail -f -n 100'

# Shell Prompt customization (cygwin or unix version)
#=================================================
export PS1="\n[xb@dell:\w]\$ "

##################################################
# END .bashrc
##################################################
  • Use SSH ssh-keygen2 to generate public and private keys, scp public key to remote server's .ssh directory, cat public key to authorized_keys. Open file hosts at C:\Windows\System32\drivers\etc to add the ip address and a brief hostname for your remote server. Use ssh username@remote_hostname to login in the future.