You are here: Home Tech Notes Linux
Linux - Tech Notes



SSH: Stop Asking to Add New Hosts PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Tuesday, 29 December 2009 11:33

An annoying little thing. When connecting via SSH to another machine for the first time SSH always prompts;

---
The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is ..............
Are you sure you want to continue connecting (yes/no)?
---

Typing "yes' each time can be pain in the butt. There is a way to change that behavior but, some believe it exposes you to a Man-in-the-middle attack.You've been advised!

I've changed settings in most of my /etc/ssh/ssh_config files to stop the machine from begging for a "yes" response, to just automatically adding the new host to the known_hosts file. I did that by changing the parameter value of StrictHostKeyChecking to "no" and restarting the SSH service.

Note: This does not stop SSH from checking that the host exists in the known_hosts file. It simply adds new hosts to the file without prompting.

 
PHP CLI: Rsync Script PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Wednesday, 23 December 2009 17:01

Here's a handy script to run rsync from the command-line that prompts for source and destination paths;

#! /usr/bin/php

<?php
## Control CLI parameters
if (($argv[1]=="") OR ($argv[2]=="")) {
echo "Options not specified.\r\n";
echo "Program Usage: ";
echo $argv[0]." <i.e.: /source/path> <i.e.: /destination/path>\r\n\r\n";
exit;
}else{
$srcpath=$argv[1];
$dstpath=$argv[2];
}

$starttime=date('G:i:s', strtotime('now'));

echo "Starting rsync...\r\n";
$retval=system("sudo rsync -avrl --delete ".$srcpath." ".$dstpath, $retval);
if (!$retval==false) {
echo "Backup from ".$srcpath." to ".$dstpath." is complete!\r\n\r\n";
}else{
echo "Backup from ".$srcpath." to ".$dstpath." FAILED!\r\n\r\n";
}

$endtime=date('G:i:s',strtotime('now'));


echo "\r\nStart time - ".$starttime."\r\n";
echo "End time - ".$endtime."\r\n\r\n";
echo "Script complete!\r\n";

?>

Note:

  • The sudo command in the system call allows the script to be used to sync root user files. This can be removed if that behavior is not desired.
  • The script also utilizes the --delete feature of rsync to remove files in the destination that do not exist in the source. Evaluate that behavior for your application as well.
 
Ubuntu: Change Hostname PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Monday, 02 November 2009 09:20

I had to snag this one for posterity from http://www.ducea.com/2006/08/07/how-to-change-the-hostname-of-a-linux-system/

 

Permanent hostname change on Debian based systems

Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh

/etc/hostname
server

So on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run:

/etc/init.d/hostname.sh start

to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we used hostname.sh).

 
Linux: Copy Directory Structure Only PDF Print E-mail
User Rating: / 2
PoorBest 
Tech Notes - Linux
Written by Rick   
Friday, 11 September 2009 18:00

I ran across the need to copy a large directory structure to a remote machine this week. I just needed the directory structure, not the files. There is a way to do this locally using the cp command with the --parent switch, though I haven't tried it yet.

Doing it remotely requires rsync;

rsync -av --include '*/' --exclude '*' source-dir dest-dir

Works like a charm.
 
Ubuntu Jaunty: Restore Firefox and/or Thunderbird from Backup PDF Print E-mail
Tech Notes - Linux
Written by Rick   
Wednesday, 02 September 2009 12:00

Last weekend I decided it was time for a fresh installation of Ubuntu Linux. Upgrading from version to version sometimes leaves your system a little "off". So, I generally do a fresh installation every second or third release just to keep things neat and to use new or upgraded features. Network Manager comes to mind, it was a little buggy after upgrading. And I had some really weird stuff happening when I'd modify a text document over the internet, like the entire content of the document would be appended to the file upon saving, every save. Rather than spend the time debugging, a new installation was the way to go.

Read more...
 
Linux: Get Information About Your Hard Drive PDF Print E-mail
User Rating: / 1
PoorBest 
Tech Notes - Linux
Written by Rick   
Monday, 31 August 2009 17:08

Linux has many tools that can mystify a new user. A whole new world of information and manipulation awaits you with hdparm.

Hdparm is a CLI utility that reveals all types of things about your hard drive. For example, hdparm -tT /dev/sda (replace sda with your appropriate device) performs a quick timed cache and buffer read test. This allows you to detemine if the drive has slowed which could indicate an impending problem with the drive.

The utility also can be used to provide oodles of information about the drive, from identifying the manufacturer and model to getting the parameters and much more.

With the capability to put a drive to sleep, change it's acoustic parameters and various other modes, I can see where it would have some data recovery applications too.

Caveat: Hdparm has some destructive capabilities that should be used only after due research and some practice on a non-critical drive.

 
<< Start < Prev 1 2 3 4 5 Next > End >>

Page 1 of 5