≡ Menu


Squid Listen on Other Port ( Squid Configure Port Listing with SELinux)

My Squid proxy server running on port 3128. Since this is frequently scanned by adversaries looking for proxy servers; I've changed port to 10000 and restart squid. But my squid is not working on port # 10000 it only works on port # 3128? How do I force Squid to listen on uncommon port under CentOS Linux v5.3?
[click to continue…]

What Is The Difference Between Authentication And Authorization?

What is the difference between authentication and authorization? Why it is important to understand difference between the two? Authentication vs. Authorization -- what are they and how do they differ?
[click to continue…]

Postfix Configure Multiple ISP Client SMTP Authentication

How do I support multiple ISP accounts (smarthost) in the Postfix SMTP client for relaying email? For example:

[a] user1@isp1.com must be relay via smtp.isp1.com.
[b] user1@isp2.com must be relay via smtp.isp2.com.
[c] me@mycorp.com must relay all my default email via smtp.mycorp.com.
[click to continue…]

SSH Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys2

I'm trying to login using ssh keys but server is only allows to login me using a password. The following message is logged into server /var/log/secure file:

Feb 25 06:36:50 ns5 sshd[26681]: Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys2

How do I fix this problem?
[click to continue…]

Proftpd: Make Sure FTP Client Does Not Timeout

Q. I'm using ProFTPD FTP server under CentOS Linux. How do I make sure that my FTP client does not disconnect or timeout connection to FTP server?
[click to continue…]

Fedora 10 Enable GUI Root Login

Q. How do I enable root login under Fedora 10 Gnome GUI login screen / manager?
[click to continue…]

sshpass: Login To SSH Server / Provide SSH Password Using A Shell Script

How do I login over ssh without using password less RSA / DSA public keys? How do I use ssh in a shell script? How do I login non-interactivly performing password authentication with SSH and shell scripts?
[click to continue…]

How to backup the remote files in Linux / UNIX

Q. How do I make remote backups under Linux? I’ve CentOS 5 Linux server located in remote data center and I’d like to backup it to local or another server?

A. Both Linux / UNIX come with handy tools to make secure remote backups. You can use tool called rsync for automating remote backups of your Linux, UNIX, Windows server, Mac OS X and BSD systems. rsync is a program with many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated.

Task: Copy files / backup files from remote Linux server

Let us say you would like to backup files from remote server called server.nixcraft.in and directory called /home/vivek to local directory called /backup, type the command as follows on local system:
$ rsync -avz -e ssh vivek@server.nixcraft.in:/home/vivek/ /backup
You need to supply password for vivek user.

Task: Exclude files from backup

You can also skip few files from backup. Let us say you don't want to backup all C source code file, enter:
$ rsync --exclude '*.cpp' -avz -e ssh vivek@server.nixcraft.in:/home/vivek/ /backup

Task: Automatic backup using a shell script

SSH always prompts for a password. To automate process via a shell script you need to remove password using SSH key i.e. generate passphraseless keys, enter (type at local system):
$ ssh-keygen -t dsa
When asked for to enter passphrase, just press [ENTER] key twice. Now copy public key to remote server:
$ scp ~/.ssh/id_dsa.pub vivek@server.nixcraft.in:.ssh/authorized_keys
Now you can login without a password. For more information see - howto setup SSH with DSA public key authentication and RSA key authentication for password less login.

Now create a simple shell script as follows:
$ vi backup.sh
Append code:
rsync --exclude '*.cpp' --exclude '*.log' -avz -e ssh vivek@server.nixcraft.in:/home/vivek/ /backup

Setup executable permission using chmod command:
$ chmod +x backup.sh
Use cron to command to backup remote server:
$ crontab -e
Make a backup everyday:
@daily /path/to/backup.sh
Save and close the file.

Linux / UNIX generate htpasswd to store username and password with htpasswd command

Q. How do I use htpasswd command to store username and passwords?

A. htpasswd is used to create and update the flat-files used to store usernames and password for basic authentication of HTTP users. If htpasswd cannot access a file, such as not being able to write to the output file or not being able to read the file in order to update it, it returns an error status and makes no changes.

Create a new password file

Following command will creates a new file and stores a record in it for user jerry. The user is prompted for the password. If the file exists and cannot be read, or cannot be written, it is not altered and htpasswd will display a message and return an error status.
# htpasswd -c /home/pwww/.htpasswd jerry

Change or update password

To add or modifies the password for user tom, enter:
# htpasswd /home/pwww/.htpasswd-users tom

The user is prompted for the password.

See previous FAQ : Apache password protect directories with .htaccess file for more examples.