Coredump

Work, play, and everything in-between.

Archive for the ‘unix’ tag

Using screen

without comments

My work setup is like this: I have two monitors, one for a maximized Thunderbird window, and the other for a PuTTY window, Firefox, Outlook (minimized to tray, and only used for calendar reminders mostly), and IE. Well, I do open other windows, but I tend to use the above most often.

I use PuTTY extensively to manage remote Unix systems. I also like my desktop uncluttered, so instead of multiple PuTTY windows, I only use one. I log on to a “jump” host, fire up `screen`, and I’m all set.

At home, I have a similar setup. Below is my .screenrc:

# Default sessions
screen -t MISC 4
screen -t EVEY 4
screen -t INES 3
screen -t IANDEXTER_COM 2
screen -t IANDEXTER_NET 1
screen -t HOME 0
 
# Scrolling buffer
defscrollback 99999
altscreen on
 
# PuTTY fix
term xterm
termcapinfo xterm ti@:te@
 
# Status line
hardstatus alwayslastline
hardstatus string '%{= kG}%-Lw%{= bW}%50> %n %t %{= kG}%+Lw%< '
 
# Key bindings
bindkey -k k6 detach
bindkey -k k7 quit
bindkey -k k8 hardstatus alwayslastline
bindkey -k k9 hardstatus alwaysignore
 
# Other stuff
startup_message off
autodetach on
defutf8 on
crlf off
setenv LC_CTYPE en_US.UTF-8

The Default sessions section opens up windows for my other hosts (guess how I name my boxes ;)). I also have a pretty large scroll buffer — useful when tailing logs. The hardstatus lines show the sessions and highlights the active one. I got the (not-so) fancy-schmancy color codes from here. Lastly, I bind the F6 to F9 keys to, respectively, detach the screen session, quit screen, toggle off the status line, and put it back on.

My .screenrc at work is more or less the same, except for the sessions I open. I can also tellscreen to use a different shell (I’m an unabashedly Bash fan, heh) apart from what is default in the systems I manage.

Written by Ian Dexter

October 14th, 2008 at 2:59 am

Posted in Play, Work

Tagged with , , , , , ,

Quick directory switching

with 3 comments

At work, I do a lot of directory traversal: going from one location to another within the whole (global) filesystem structure. So, to conveniently go back to a previous directory, I use pushd and popd, aside from the usual cd:

$ pwd
/home/iandexter
$ pushd /etc/sysconfig
$ pwd
/etc/sysconfig
$ popd
$ pwd
/home/iandexter

You can even echo $DIRSTACK to list the current directories in the stack, and push multiple directories.

Written by Ian Dexter

August 17th, 2007 at 2:07 am

Posted in Play, Work

Tagged with , , , , , ,

Quickies

with one comment

  • Work: Gone Unix-hardcore. Our team currently leads Unix training for other infra teams. Shell/Perl scripting occupies a large part of the, er, curriculum. I’m “re-learning” Perl. I’m also amazed as to how open source is being leveraged here. I lurve open source.
  • Family: Prior to a change of shift sked, I go on an extended off-shift period of four days. Like, wow! What better way to start that four-day weekend than to slooowly fry in my own oil (not a nice imagery there) here at the airport. Hooray. Love the company, though, as always.
  • Others: I still haven’t gotten around to reading Good Omens. Haven’t watched Harry Potter, too. (Why bother? I heard it’s not as good as the book, anyway.) And, I haven’t been online in a while. Smart 3G’s a big bummer. Been getting lots of connection errors lately. Hope it stabilise soon.

Written by Ian Dexter

August 3rd, 2007 at 11:12 pm

Posted in In-between

Tagged with , , , , ,

Long night

without comments

I’m still here at the office, watching text scroll down (or is it up?) the monitor. Actually, I’m backing up the whole /var partition from one of the mail servers, to make way for a larger capacity disk.

You’re thinking, duh, LVM. But this server had been set up way before LVM became stable. I could not even back up to tape — not yet, at least — because I have to get this up and fast, while keeping the server live, so I’m doing it over (of all things) USB, and 1.1 at that.

(Heh, fast. I’ve been at it since 5 PM, and I’m not nearly halfway done. *sigh* Such is life.)

Written by Ian Dexter

February 14th, 2007 at 2:00 am

Posted in Work

Tagged with

Windows-to-*nix public key authentication

without comments

I’ve worked with lots of servers, most of which I cannot access directly, so I often use remote access: Remote Desktop Connection or Terminal Services in Windows, and ssh in *nix.

While I do have PasswordSafe to remember all those passwords, I’m the lazy admin type, so I often opt for password-less authentication using public keys. For this, I use PuTTY, et. al.

  1. First, I generate an RSA key using PuTTYgen. I don’t enter anything for the passphrase. Warning: NOT recommended for production servers!
  2. I save the public and secret keys (in .PPK format) in a directory. I also cut and paste the RSA string in a text file, key.txt.
  3. For now, the remote box is configured for “normal” ssh, that is, through password authentication. So, I copy over the RSA string file to the remote box:
    C:\> pscp \path\to\key.txt user@remote-host:/home/user/.
  4. I log on to the remote host using PuTTY, and do the following:

    $ mkdir .ssh
    $ mv key.txt .ssh/authorized_keys
    $ chmod 700 .ssh; chmod 600 .ssh/authorized_keys
  5. I also edit the SSHd config file, /etc/ssh/sshd_config, with the following parameters:
    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile     .ssh/authorized_keys
    PasswordAuthentication no
    PermitRootLogin no
  6. SSHd is then restarted.
  7. Back in Windows, I launch PuTTY, and enter the host name for the remote box. In the SSH/Auth category, I place the private key file saved earlier. I save the session, named remote-nopass.
  8. I then launch Pageant, drill down to Saved Sessions > remote-nopass. It will bring up the SSH login page, where I enter my login name, after which, I am authorized through the pubkey, and log in to the SSH session.

Seems tedious at first, but I can then export key.txt to other remote servers, and just save sessions for Pageant’s use. Pageant is conveniently located in the system tray within reach.

Written by Ian Dexter

January 18th, 2007 at 6:29 pm

Posted in Play, Work

Tagged with , , , ,