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