A hack for mintty to use as Windows command console cmd

If you’re like me, vain in changing the Windows command console (cmd.exe) and if you like the functionality and look and feel of mintty (cygwin), here’s how to change the look and feel of cmd.exe:

  1. Install Cygwin with Shells -> Mintty included.
  2. start <cygwin directory>/bin/mintty %COMSPEC%

Start is a windows command for spawning new applications.

<cygwin directory>/bin/mintty is the application you want to start.

%COMSPEC% is the parameter for mintty.  Windows will substitue this to cmd.exe.  Well you can call it directly using “start <cygwin directory>/bin/mintty cmd.exe”

Example screehshot:

Hope this helps

Advertisements

Am I *TOOL* dependent?

One of my colleagues struck me by saying “you are tool dependent”.   From the very moment he said that to me, I agree deep within – although I never answer or loudly answer YES.  I know what he means by that and now I’m asking myself that very question.  In order to answer that question, lets define first what being tool dependent is?

  • Explores a lot of tools, recursively
  • Is lazy
  • Yet is ideal
  • The goal is to produce or optimize things with very little effort
  • Does not focus on the subject matter but instead focuses on the tools to accomplish the problem or the subject matter
  • Kills time for tool exploration
  • Plays alot with the tools
  • Spends time doing boilerplate codes
  • A tool slave – relies on the tools very much
  • Always buying time or always lacks time
  • Never get things done
  • Couldn’t get things done without the tools
  • Having a hard time controlling oneself
  • Does not have self-discipline
  • Have an attention deficit disorder
  • Easily persuaded by tools
  • Jack of all trades, master of none
  • Critical thinker
  • Creative thinker to the point of once a problem occurs, the solution instantaeneously pops out of the brain and then performs research about what tool accomplishes the problem instead of analyzing the problem first and then acting after.
  • An action man without thinking first
  • You overly submit oneself to that way
  • Has a lot of options because of the result of finding a lot of possible tools and solutions to solving a particular problem.
  • Always planning to escape being tool dependent but cannot
  • Tends to over-analyze things

From this definition alone, I would say I am.  Well, I just made up this definition from what I understand to be a tool dependent.

Upon reflecting, here I think are ways to escape from being a tool dependent person.

  • A determination to change
  • An everyday re-assessment of goals if it gets done
  • Focus and focus on solving the subject matter by not relying from the tools
  • Organize
  • Follow up
  • Focus on personal development – by not using those tools
  • Have a general sense of whats happening – have a birds eye view
  • Think first before acting
  • Always rely to oneself.  Don’t be dependent to things – and don’t escape the situation
  • Develop a sense of independence
  • Believe in your own competency
  • Gain personal mastery and self-control

Systematic way of tackling tool dependence.

  • Being dependent on things means holding on desperately to things to give life a meaning or direction.  In this case, to give you a desired solution to the problem you are tackling.
  1. Be willing to let go of the tools.  Begin by resenting those tools that can keep you back from all that you are capable of.
  2. Have the ability to self-initiate and lead oneself.
  3. Limit the tool selection to just 3, so that at least you have the options.
  4. Don’t over-analyze things for your pleasure.
  5. Practice, practice, practice.  From what I’ve heard, all it takes to acquire a habit is to perform it for two weeks consistently.  For example, if you are lazy to brush your teeth everyday – and you want to do something about it; train your mind and *do* it for two weeks and it becomes a habit.

serialVersionUIDs for IntelliJ IDEA 9

While I was wondering why IDEA did not seem to have a generator for UIDs, I browsed the plugins and found serialver.  I find it stupid enough to use and then I research more from the Code inspections.

Steps for enabling IDEA to generate serialVersionUIDs:

  1. Click the Code Inspection icon from the lower right portion of IDEA.  The one displayed like detective.
  2. Click the Configure inspections link to see the Inspections dialog box.
  3. Find the Inspections -> Serialization issues -> Serializable class without ‘serialVersionUID’.
  4. Check it to enable it.
  5. Click OK to close the Inspections dialog box.

When editing a Serializable class without a serialVersionUID, it will display a warning and a Quickfix balloon to generate it.

Configure Pidgin for GoogleTalk in Proxy

Here’s how to configure GoogleTalk in Pidgin under a proxy server:

  1. Open Pidgin and go to Add / Edit Account window of Pidgin.
  2. From the drop-down box choose XMPP as the Protocol.
  3. For the Screen name enter your Google Id (Gmail Id without the @gmail.com). 
  4. For Server enter gmail.com

  • You can leave the Resource with the default “Home“.
  • In the Password field enter your Google ID password.
  • Enter Local alias as whatever you want to.
  1. In the Advanced tab, check Require SSL/TLS
  2. Force old SSL unchecked, and Allow plaintext auth unchecked
  3. Connect port: 5222
  4. File transfer proxies: proxy.jabber.org
  5. Select the desired proxy protocol. e.g. HTTP
  6. Enter the proxy domain host. e.g. proxy.accenture.com
  7. Enter the proxy port. e.g. 80 or 8080
  8. If your proxy requires an authentication, enter proxy username and password.

Troubleshooting errors reported:

  • HTTP proxy connection error 407
    • Means the proxy requires an authentication.  Just enter your proxy username and password.
  • HTTP proxy connection error 504
    • Means there’s a connection timeout.
    • Alternatively use this settings:
    • Require SSL/TLS: Unchecked
      Force old (port 5223) SSL: Checked
      Allow plaintext auth over unencrypted streams: Un-Checked
      Connect Port: 443
      Connect Server: talk.google.com
      Proxy type: Use Global Proxy Settings

Hope this helps!

IntelliJ Idea 8 settings

My intellij idea 8 settings found in C:\Program Files\JetBrains\IntelliJ IDEA 8.1.3\bin\:

idea.exe.vmoptions:

-Xms128m
-Xmx724m
-XX:MaxPermSize=256m
-ea

idea.properties:

# path to IDEA config folder. Make sure you’re using forward slashes
idea.config.path=${user.home}/.IntelliJIdea80/config

# path to IDEA system folder. Make sure you’re using forward slashes
idea.system.path=${user.home}/.IntelliJIdea80/system

# path to user installed plugins folder. Make sure you’re using forward slashes
idea.plugins.path=${user.home}/.IntelliJIdea80/config/plugins

My certificate: C:\Documents and Settings\<home dir>\.IntelliJIdea80\config\idea80.key

Subversion client connecting using SVN+SSH

If you have different username from the SVN remote:

Setup ssh_config
Host <www.domain.com>
User <username in the domain.com>

Subversion and SSH

Subversion allows you to use SSH as the network protocol by using the svn+ssh:// scheme in the repository URL. One downside to this is that the only way to specify your remote username is in the URL, for example:

svn+ssh://dribin@svn.example.com/repo

This is all fine and dandy if you’re just doing a checkout, but this can cause problems if you want to use the svn:externals property. If you include a username in your URL, no other user can use the external without your remote password. Ideally, you want to allow each user to use their own username in the URL. Unfortunately Subversion has no way to override the SSH username in the URL. The trick around this is to not use usernames in URLs at all:

svn+ssh://svn.example.com/repo

You can then specify your remote username in your $HOME/.ssh/config:

Host svn.example.com

User dribin

OpenSSH Public Key Authentication

Public Key Setup | Configure ssh-agent Process | Agent Forwarding

Secure Shell (SSH) public key authentication can be used by a client to access servers, if properly configured. These notes describe how to configure OpenSSH for public key authentication, how to enable a ssh-agent to allow for passphrase-free logins, and tips on debugging problems with SSH connections. Password free logins benefit remote access and automation, for example if administering many servers or accessing version control software over SSH.
Public key authenticate can prevent brute force SSH attacks, but only if all password-based authentication methods are disabled. Other options to protect against brute force SSH attacks include pam_tally, or port knocking. Public key authentication does not work well with Kerberos or OpenAFS, which require a password or principal from the client.
Definition of terms used in this documentation:

  • Client: the system one types directly on, such as a laptop or desktop system.
  • Server: anything connected to from the client. This includes other servers accessed through the first server connected to.

Never allow root-to-root trust between systems. If required by poorly engineered legacy scripts, limit the from access of the public keys, and if possible only allow specific public keys to run specific commands. Instead, setup named accounts for users or roles, and grant as little root access as possible via sudo.

For more information, see also SSH, The Secure Shell: The Definitive Guide. SSHKeyChain offers integration between the Apple Keychain and OpenSSH.

Public Key Setup

Key Generation | Key Distribution | Key Access Limits
First, confirm that OpenSSH is the SSH software installed on the client system. Key generation may vary under different implementations of SSH. The ssh -V command should print a line beginning with OpenSSH, followed by other details.
$ ssh -V
OpenSSH_3.6.1p1+CAN-2003-0693, SSH protocols 1.5/2.0, OpenSSL 0x0090702f

Key Generation

A RSA key pair must be generated on the client system. The public portion of this key pair will reside on the servers being connected to, while the private portion needs to remain on a secure local area of the client system, by default in ~/.ssh/id_rsa. The key generation can be done with the ssh-keygen(1) utility.
client$ mkdir ~/.ssh
client$
chmod 700 ~/.ssh
client$
ssh-keygen -q -f ~/.ssh/id_rsa -t rsa
Enter passphrase (empty for no passphrase): …
Enter same passphrase again: …

Do not use your account password, nor an empty passphrase. The password should be at least 16 characters long, and not a simple sentence. One choice would be several lines to a song or poem, interspersed with punctuation and other non-letter characters. The ssh-agent setup notes below will reduce the number of times this passphrase will need to be used, so using a long passphrase is encouraged.
The file permissions should be locked down to prevent other users from being able to read the key pair data. OpenSSH may also refuse to support public key authentication if the file permissions are too open. These fixes should be done on all systems involved.
$ chmod go-w ~/
$
chmod 700 ~/.ssh
$
chmod go-rwx ~/.ssh/*

Key Distribution

The public portion of the RSA key pair must be copied to any servers that will be accessed by the client. The public key information to be copied should be located in the ~/.ssh/id_rsa.pub file on the client. Assuming that all of the servers use OpenSSH instead of a different SSH implementation, the public key data must be appended into the ~/.ssh/authorized_keys file on the servers.
# first, upload public key from client to server
client$
scp ~/.ssh/id_rsa.pub server.example.org:

# next, setup the public key on server
server$ mkdir ~/.ssh
server$
chmod 700 ~/.ssh
server$
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
server$
chmod 600 ~/.ssh/authorized_keys
server$
rm ~/id_rsa.pub
Be sure to append new public key data to the authorized_keys file, as multiple public keys may be in use. Each public key entry must be on a different line.
Many different things can prevent public key authentication from working, so be sure to confirm that public key connections to the server work properly. If the following test fails, consult the debugging notes.
client$ ssh -o PreferredAuthentications=publickey server.example.org
Enter passphrase for key ‘/…/.ssh/id_rsa’: …

server$

Key distribution can be automated with module:authkey and CFEngine. This script maps public keys stored in a filesystem repository to specific accounts on various classes of systems, allowing a user key to be replicated to all systems the user has access to.
If exporting the public key to a different group or company, consider removing or changing the optional public key comment field to avoid exposing the default username and hostname.

Key Access Limits

As an optional step to limit usage of the public key for access to any servers, a from statement can be used before public key entries in the ~/.ssh/authorized_keys file on the servers to limit where the client system is permitted to access the server from. Without a from limit, any client system with the appropriate private key data will be able to connect to the server from anywhere. If the keypair should only work when the client system is connecting from a host under example.org, set from=”*.example.org before the public key data.
server$ cat ~/.ssh/authorized_keys
from=”*.example.org” ssh-rsa AAAAB3NzaC1…

If a text editor is used to add the from option, ensure the data is saved as a single line; some editors may wrap the public key and thus corrupt the data. Each public key in the ~/.ssh/authorized_keys file must not span multiple lines.
Multiple hosts or addresses can be specified as comma separated values. For more information on the syntax of the from option, see the sshd(8) documentation.
from=”*.example.org,10.*,external.example.com” …

Configure ssh-agent Process

To reduce the frequency with which the key passphrase must be typed in, setup a ssh-agent(1) daemon to hold the private portion of the RSA key pair for the duration of a session. There are several ways to run and manage ssh-agent, for example from a X11 login script or with a utility like Keychain. These notes rely on the setup of ssh-agent via an @reboot crontab(5) entry, along with appropriate shell configuration.

The ssh-agent must only be run on the client system. The private key of the RSA key pair must remain on the client system. Agent forwarding should be used to make the key available to subsequent logins to other servers from the first server connected to.

1. Startup cron job

    The following crontab(5) entry should run the agent at system startup time. The crond daemon on BSD and Linux systems should support the special @reboot syntax required for this to work.

    @reboot ssh-agent -s | grep -v echo > $HOME/.ssh-agent

    To setup the agent for the first time without having to reboot the system, run the following.

    $ nohup ssh-agent -s > ~/.ssh-agent

    Once the ssh-agent is running, any shells already running will need to source in the environment settings from the ~/.ssh-agent file. The SSH_AUTH_SOCK andSSH_AGENT_PID environment variables set in this file are required for the OpenSSH commands such as ssh and ssh-add to communicate with the ssh-agent on the client system.

    $ . ~/.ssh-agent

    Notes on configuring all shells to be able to run arbitrary commands are available. This reduces the initial setup to the following commands, which can be done from the script reagent.

    $ nohup ssh-agent -s | grep -v echo > ~/.ssh-agent

    $ allsh – < ~/.ssh-agent

    If csh or tcsh is being used instead of a Bourne-based shell, replace the -s argument with -c, and the source command used instead of . in any running shells.

    2. Shell startup script changes

      The shell’s startup script on the client system will need to be modified to pull in the required environment settings from ~/.ssh-agent and setup useful aliases. The agent settings in ~/.ssh-agent should not be read in if the client system is being connected to as a server. Remote connections set the SSH_CLIENT environment variable, so~/.ssh-agent must not be read in when this variable contains data.

      [ -z “$SSH_CLIENT” ] && . $HOME/.ssh-agent

      alias keyon=”ssh-add -t 10800″

      alias keyoff=’ssh-add -D’

      alias keylist=’ssh-add -l’

      The -t option to ssh-add will remove keys from memory after the specified number of seconds. This option prevents the keys from being left unlocked for long periods of time. Older versions of OpenSSH will not have the timeout -t option.

      For the csh and tcsh shells, slightly different configuration of the agent and aliases is required. Consult the relevant ssh-agent(1) and shell documentation.

      Once the ssh-agent is running and shell configured to read in the appropriate settings and set easy aliases, enable the key then test a login to a remote server. Thekeyon will only need to be run when initially adding the private key data to ssh-agent, and only rerun if ssh-agent is restarted or the key is removed with keyoff.

      client$ keyon

      client$ ssh server.example.org
      server$ exit
      client$ keyoff
      Use the keylist command to see what keys are in the agent process.

      $ keylist

      1024 01:a1:aa:34:21:bc:7d:a4:ea:56:a4:a1:1a:c5:fa:9f /home/…/.ssh/id_rsa (RSA)
      If password free logins do not work, see tips on debugging problems with SSH connections to work out where the problem may be.

      To make other applications not run from a shell aware of the agent, the environment definitions in the ~/.ssh-agent file will need to be read into the software in question. Consult the documentation for the software to see whether this is possible.

      Agent Forwarding

      For simple client to server connections, SSH agent forwarding will not be a concern. However, if from the server connected to, one logs into other servers, SSH agent forwarding will need to be enabled. If SSH agent forwarding is disabled, a private key must be available on the proxy system that is recognized by the server being connected to.
      To enable forwarding, either use the -A option to ssh when connecting, or set ForwardAgent in an OpenSSH config file, such as ~/.ssh/config. Note that command line arguments override the user-specific configuration file, which in turn can override the global ssh_config configuration file, if any.
      Host *

      ForwardAgent yes


      ForwardX11 no

      Agent (and X11) forwarding may represent a security risk, providing more options to an attacker on a compromised server to work back to the client system. If paranoid, disable Agent and X11 forwarding by default, and only enable the features where needed. Also enable StrictHostKeyChecking and use configuration management software such as CFEngine to distribute a global ssh_known_hosts file to all client systems.