Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, July 3, 2013

Remove offending RSA key in ~/.ssh/known_hosts file with one line command

Remove offending RSA key in ~/.ssh/known_hosts file with one line command


When you ssh to a server where the host key (RSA) has changed then you will get an error message as shown in the image:













The error in the above example :

Offending RSA key in /home/username/.ssh/known_hosts:8



Looking in to the error message, we can find the offending RSA key and its position in the known_hosts file. In the above example image the offending key is at  line 8. (

Tuesday, July 2, 2013

Remote shutdown one line ssh command

Remote shutdown one line ssh command

Q.) How to shut down / restart  a remote linux server from ssh ?



A.)  ssh -t user@hostname 'sudo shutdown -P now'



In the above example

-t  : forces the allocation of a tty for the command.

-P : stands for power off.

-r  : to reboot.

-h : to halt. 



Also all the shutdown arguments can be passed along. To know more about shutdown options run command.

shutdown --help





Wednesday, May 2, 2012

Install openvpn on ubuntu VPS in less than 10 minutes

Install openvpn on ubuntu VPS in less than 10 minutes




Overview


If all that you want is just a openvpn server without the hassle of compiling, I recommend a debian / ubuntu system with a minimum of 64mb RAM. The below instructions would let you connect to your own openvpn (openvz VPS) server in less than 10 minutes.









Prerequisite

Before we install openvpn, check if tun/tap is enable for your vps:

cat /dev/net/tun 



In the above image

Tuesday, May 1, 2012

Setup ramdisk with ramfs or tmpfs

Setup ramdisk with ramfs or tmpfs




Overview:

Using ramfs or tmpfs you can allocate part of the physical memory to be used as a partition. You can mount this partition and start writing and reading files like a hard disk partition. Since you’ll be reading and writing to the RAM, it will be faster.



When a vital process becomes drastically slow because of disk writes, you can choose either ramfs or tmpfs file systems for
ramfs manpage

ramfs manpage



NAME
ramfs  - memory file system

SYNOPSIS
ramfs [ -Dipsu ] [ -m mountpoint ] [ -S srvname ]

DESCRIPTION
Ramfs
starts a process that mounts itself on mountpoint
(default /tmp).  The ramfs process implements a tree rooted at dir,
keeping all files in memory.  Ini- the file tree is empty.

The -D option enables a trace of general debugging

The
-i flag tells ramfs to use file descriptors 0

Friday, April 6, 2012

create terminal bash shortcuts

create terminal bash shortcuts

You can assign shortcuts for your most frequently used terminal commands by appending alias as many times as you did like to your bash configuration file (~/.bashrc). The syntax for alias is as follows.



alias yourCommand="YourTerminalCommand"



example:

alias la="ls -la"

alias gs1="ssh gs1.yourdomain.com"







Aliases shorten the amount of keystrokes necessary to throw commands.



I put
Common Linux commands on system info

Common Linux commands on system info



pwd 

Print working directory, i.e., display the name of my current directory on the screen.



hostname 

Print the name of the local host (the machine on which you are working). Use netconf (as root) to change the name of the machine.



whoami 

Print my login name.



id username 

Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the

Monday, April 2, 2012

perl: warning: Setting locale failed

perl: warning: Setting locale failed

I get this error while updating and installing software : perl: warning: Setting locale failed

perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to

Friday, March 30, 2012

How to secure a VPS

How to secure a VPS


To disable Formmail in order to stop spam mails -

1) Command to find Mails -
find / -name “[Ff]orm[mM]ai*”

2) Command to find CGI mails -
find / -name “[Cc]giemai*”

3) To disable form mails -

chmod a-rwx /path/to/filename

this is will disable all the scripts.

B) Root kits should be installed -

- Set a root kit on a cron job, this will show if any one has hacked in the roots.
- Update the
Set Linux local timezone for VPS

Set Linux local timezone for VPS


This guide describes how to set the Linux local timezone.


ls /usr/share/zoneinfo/  and note the region where you reside 
ls /usr/share/zoneinfo/ (where is your local region) and note the timezone which corresponds to your location 

For Ubuntu
ln -sf /usr/share/zoneinfo// /etc/localtime 


For Debian
ln -sf /usr/share/zoneinfo/<

Thursday, March 29, 2012

Common iptables sample

Common iptables sample


# Modify this file accordingly for your specific requirement.
# 1. Delete all existing rules
iptables -F

# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# 3. Block a specific ip-address
#BLOCK_THIS_IP="x.x.x.x"
#iptables -A INPUT -s "$BLOCK_THIS_IP" -j DROP

# 4. Allow ALL incoming SSH
#iptables -A INPUT -i eth0 -p tcp --dport 22 -m state
Syslog file is not readable, read access may be denied

Syslog file is not readable, read access may be denied





User permissions in syslog files are 640 but for LogAnalyzer to work syslog files must be readable by www-data. Below are the steps to make syslog readable



1. First add a new group by using this command, we call the group logadmin in this sample.

     groupadd logadmin



2. Now we add the www-data user to the new created logadmin group!

     usermod -a -G logadmin www-data



3. Verify
How to make syslog files readable by default on ubuntu?

How to make syslog files readable by default on ubuntu?


We installed LogAnalyzer for easy analysis and reporting of the server.  For this syslog files must be readable by www-data. Below are the steps to make syslog readable


1. First add a new group by using this command, we call the group logadmin in this sample.

     groupadd logadmin



2. Now we add the www-data user to the new created logadmin group!

     usermod -a -G logadmin www-data



3