Linux SSH Tips

2011/07/21 張貼者: Damon.Huang 0 意見
Multiple Connections
第一次連線成功後,再開一個視窗連線同一台主機時,就會用原本的連線來進行連接,也不需要再輸入一次密碼
# vi ~/.ssh/config 
加入以下兩行
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
Avoiding Delays
連線到其他主機時,在出現詢問密碼時,要經過幾十秒的等待
# vi ~/.ssh/config 
GSSAPIAuthentication no
也可直接修改 /etc/ssh/sshd_config
# vi /etc/ssh/sshd_config
GSSAPIAuthentication no
GSSAPIDelegateCredentials no
Example:
##############################
# Connection sharing
##############################
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r

##############################
# Persistent connections(4 hrs)
##############################
ControlPersist 4h

##############################
# Hostname Aliases
##############################
Host o1
HostName srv1.example1.com

Host o2
HostName srv2.example1.com
User root

Host neb1
HostName srv3.example2.com
User root

Host neb2
HostName srv4.example2.com
User root

##############################
# Avoiding Delays
##############################
GSSAPIAuthentication no

Reference:

標籤: ,

如何在Ubuntu 編譯 Vim

2011/07/19 張貼者: Damon.Huang 0 意見
下載 Source Code
Vim 是用 Mercuial 來做版本控制,所以要安裝 Mercuial 才能進行下載 Source Code.
# sudo apt-get install mercuial 
# hg clone https://vim.googlecode.com/hg/ vim73 
Compile Source Code
建立Compile Souce Code 的 Shell script.
# cd vim73
# touch compile-custom
# chmod +x compile-custom
# vi compile-custom
將以下內容貼入檔案
#!/bin/bash
export CONF_OPT_OUTPUT='--enable-fontset'
export CONF_OPT_INPUT='--enable-xim'
export CONF_OPT_GUI='--enable-gui=gtk2'
export CONF_OPT_PYTHON='--enable-pythoninterp'
export CONF_OPT_RUBY='--enable-rubyinterp'
export CONF_OPT_PERL='--enable-perlinterp'
export CONF_OPT_MULTIBYTE='--enable-multibyte'
export CONF_OPT_FEAT='--with-features=huge'
export CONF_OPT_COMPBY='--with-compiledby=Damon Huang'

# Prepare environment  
# X11 
apt-get install libx11-dev xorg-dev 
 
# GTK2 
apt-get install libgtk2.0-0 libgtk2.0-dev 
 
# Python 
apt-get install python python-dev 
 
# Ruby 
apt-get install ruby ruby-dev 
 
# curses 
apt-get install libncurses5-dev 
 
cd src 
make distclean 
./configure $CONF_OPT_FEAT $CONF_OPT_GUI $CONF_OPT_INPUT $CONF_OPT_OUTPUT $CONF_OPT_MULTIBYTE $C
make VIMRCLOC=/etc VIMRUNTIMEDIR=/usr/share/vim/vim73 MAKE="make -e" 
make install 

update-alternatives --install /usr/bin/editor editor /usr/bin/vim 50
update-alternatives --install /usr/bin/vi vi /usr/bin/vim 50 
執行Script
# ./configure-custom
更新方式(好像也可以用上Patch方式來更新,但似乎也是要重新編譯)
# cd vim73
# hg pull
warning: vim.googlecode.com certificate with fingerprint ed:19:7c:b9:a3:48:27:93:72:74:43:db:26:40:af:e0:7a:90:1c:97 not verified (check hostfingerprints or web.cacerts config setting)
pulling from https://vim.googlecode.com/hg/
searching for changes
adding changesets
adding manifests
adding file changes
added 30 changesets with 55 changes to 23 files
(run 'hg update' to get a working copy)

# hg update
23 files updated, 0 files merged, 0 files removed, 0 files unresolved

# ./configure-custom 


標籤:

PostgreSQL 8.4 開啟遠端連線方式(Remote TCP/IP connections)

2011/07/15 張貼者: Damon.Huang 0 意見
預設 PostgreSQL 不開放由本機以外的主機連線,因此如果要由其他主機連線時,需要做以下的設定:

編輯 postgresql.conf
# vi /etc/postgresql/8.4/main/postgresql.conf
找到下面這一段
#listen_addresses = 'localhost'    => 預設是 localhost
改為   
listen_addresses = '*'             => for all 
Restarting Service
# service postgresql restart

Reference

標籤:

PostgreSQL 操作備忘

2011/07/14 張貼者: Damon.Huang
在安裝 Open Source 的系統時,有的會使用 PostgreSQL 作為資料庫,備忘一下!

  • Creating a Database - 建立資料庫
  • Syntax: 
      CREATE DATABASE dbname OWNER rolename;
    Ex:
      postgres=# CREATE DATABASE blah OWNER qoo;
    
    一般如果用套件安裝的話,可以直接在系統下建立
    Syntax: 
    # createdb -O rolename dbname
    
  • Destroying a Database - 刪除資料庫
  • Syntax: 
      DROP DATABASE name;
    Ex:
      postgres=# drop user qoo;
    
  • Creating User - 建立使用者
  • Syntax: 
      CREATE USER qoo;
    
  • 更換密碼
  • postgres=# alter user pgsql with password 'pgsql_password';
    
標籤:
技術提供:Blogger.