Perl-Expect
It's been a long time since I actually wrote a program to solve a problem. Ditch the previous post, 'cuz I found a much better SSH daemon for Win called
FreeSSHD which lets you run it with "ssh host command" just like I wanted. But even with a help page I found on the topic, I was unable to configure it to work without requiring a password, so I decided to finally get down to Expect (something I've claimed to know, tho' I never got it working to simulate a telnet job like I wanted) and found out that this code works!
#!/usr/bin/perl
use Expect;
my $timeout=2;
my $exp=Expect->spawn("ssh xtp2 \"cmd.exe /c dir\"");
$exp->expect($timeout,
[ "password:" => sub { my $self = shift;
$self->send("root123\n")
} ]
);
$exp->soft_close();
SSH on Windows!
Oh yes, I got
this package and actually used PuTTY to ssh to my Windows machine and ran dir! :)
rexec would work, but I couldn't find rexecd.
Ubuntu
Its been all of seven months off this blog, but get ready for its rebirth 'cuz
Ubuntu has breathed a new lease of life into my Linux World! All you have to do is enter your postal address
here (which is what I did) and they send you free CDs within a month!
I'm impressed!!I cannot but regale you with the exciting new features you have, which leaves Fedora way behind. 6.06 LTS (Long Term Support) was released in June '06. It comes with:
1. Firefox Version 1.5.0.3Get
Google Browser Sync to get all your settings (saved passwords, bookmarks, etc.) from Windows to Ubuntu.
2. Evolution with MS Exchange supportNo more entering
hajjar server hostnames/IP addresses and obscure username/password combinations to get it working. All it asks for is your OWA (Outlook Web Access) URL and your login/password and tada! Its all there up and running. What's more, the GAL (Global Address List) works.
3. RhythmboxiTunes-like music player which has Library, Podcasts, Sharing and even support for your iPod, from which it lets you play off everything (once you have the codecs installed, which I'll describe how to do shortly) even (I suspect) if your PC is not synced with the iPod (!!!)
The first thing you have to do after you've installed it, is to get
Easy Ubuntu or
Automatix, which gives you all the codecs you need to get started on MP3s, DVDs and whatnot. For this, I faced huge difficulties to configure my HTTP Proxy with Authentication. Finally, I put this in my .bashrc:
export http_proxy=
"http://(workgroup)\\(username):(password)@(proxy):(port)/"
export ftp_proxy=
"http://(workgroup)\\(username):(password)@(proxy):(port)/"
and PHEW! Its working now! Here's a screenshot by the way:
More later...
Hash
My new teammate is a Mandhala-like Gulti character. Quite fundoo (Thank God I didn't get some dumbass) and (almost;) as fast as I am. I've had a lot of technical quarrels with him and most are left hanging. One conclusive blow from either of us would settle all in one's favor.
We are dealing with associative arrays today at the advanced perl session. My teammate stated that the hash key contains the memory location of the corresponding hash value. I retorted that this need not be true. He was supported by the facilitator too. This
SUN docs page cache saved face!
Forgot root password?
Gaurav gave me this useful tip:
Allow the system to reboot to the GRUB splash screen, and then press "e". Select the line containing "kernel", and press "e" again. GRUB will display the line in edit mode. Add "single" to the end of the line, and press return. GRUB will return you to the previous screen. Press "b" to boot the system into what will now be single user mode. The system will come part of the way up, and then drop you into a root shell - the prompt will look like this: sh-2.05# _
Type "passwd" and set a new password. Type "exit"
[Listening to: Led Zeppelin - Physical Graffiti - Kashmir (8:32)]
SSH without password
Realised that if they took this page off, we'd be done for, so I've decided to duplicate it here.
Courtesy:
RangaThe following steps can be used to ssh from one system to another without specifying a password.
1. On the client run the following commands:
$ mkdir -p $HOME/.ssh
$ chmod 0700 $HOME/.ssh
$ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P '' This should result in two files, $HOME/.ssh/id_dsa (private key) and $HOME/.ssh/id_dsa.pub (public key).
2. Copy $HOME/.ssh/id_dsa.pub to the server.
3. On the server run the following commands:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys2
$ chmod 0600 $HOME/.ssh/authorized_keys2 Depending on the version of OpenSSH the following commands may also be required:
$ cat id_dsa.pub >> $HOME/.ssh/authorized_keys
$ chmod 0600 $HOME/.ssh/authorized_keys An alternative is to create a link from authorized_keys2 to authorized_keys:
$ cd $HOME/.ssh && ln -s authorized_keys2 authorized_keys 4. On the client test the results by ssh'ing to the server:
$ ssh -i $HOME/.ssh/id_dsa server 5. (Optional) Add the following $HOME/.ssh/config on the client:
Host server
IdentityFile ~/.ssh/id_dsa
This allows ssh access to the server without having to specify the path to the id_dsa file as an argument to ssh each time.
Helpful manpages:
* ssh(1)
* ssh-keygen(1)
* ssh_config(5)
File associations in Fedora
Needed to open MP3 files with XMMS by just double-clicking them in Nautilus, so I looked up on how to change file associations. The Fedora Forum rocks! I
learnt its quite a task! Here's how (with mplayer as example):
-> /usr/share/applications/[application_name].desktop
This is the file where "defaults.list" will point to. One of the most important things inside this file is the entry "MimeType=".
E.g: vi /usr/share/applications/mplayer.desktop
[Desktop Entry]
Name=Movie Player
Comment=Play multimedia files and media
Icon=mplayer.xpm
Exec=mplayer %f
Terminal=false
MimeType=video/mpeg;video/x-msvideo;video/quicktime;video/x-ms-asf;video/x-ms-wmv
Type=Application
Categories=Application;AudioVideo;
Encoding=UTF-8-> /usr/share/applications/defaults.list
This file contains the applications which cause a double-click success. All Mime types will point to a desktop file.
E.g: Separate multiple app names with ;'s.
video/x-ms-asf=mplayer.desktop
video/x-ms-wmv=mplayer.desktop-> /usr/share/applications/mimeinfo.cache
Contains information in similar form shown for file "defaults.list" in same directory. This file contains ALL associations given to a mime type. There is no need for a specified order of desktop files.
E.g: Repeat above
To do the same for XMMS, replace
realplayer.desktop with
redhat-audio-player.desktop in all these files..