Passwordless SSH authentication with Putty

Putty from here. Download  PuttyGen from same link. Once installed, open Puttygen and create a new pair of keys by clicking the “Generate” button. You can keep all the options at their default settings. It might be a good idea to set a passphrase for your key. Then, save both public and private key to a safe location. Name your public key <your_key_name>.pub and the private key <your_key_name>.ppk.

Continue reading ‘Passwordless SSH authentication with Putty’

HOWTO SSH back door?

Many times I’ll be at a site where I need remote support from someone who is blocked on the outside by a company firewall. Few people realize that if you can get out to the world through a firewall, then it is relatively easy to open a hole so that the world can come into you.

In its crudest form, this is called “poking a hole in the firewall.” I’ll call it an SSH back door. To use it, you’ll need a machine on the Internet that you can use as an intermediary.

In our example, we’ll call our machine blackbox.example.com. The machine behind the company firewall is called ginger. Finally, the machine that technical support is on will be called tech. Figure 4 explains how this is set up.

figure4

Here’s how to proceed:

1. Check that what you’re doing is allowed, but make sure you ask the right people. Most people will cringe that you’re opening the firewall, but what they don’t understand is that it is completely encrypted. Furthermore, someone would need to hack your outside machine before getting into your company. Instead, you may belong to the school of “ask-for-forgiveness-instead-of-permission.” Either way, use your judgment and don’t blame me if this doesn’t go your way.

2. SSH from ginger to blackbox.example.com with the -R flag. I’ll assume that you’re the root user on ginger and that tech will need the root user ID to help you with the system. With the -R flag, you’ll forward instructions of port 2222 on blackbox to port 22 on ginger. This is how you set up an SSH tunnel. Note that only SSH traffic can come into ginger: You’re not putting ginger out on the Internet naked.

You can do this with the following syntax:

~# ssh -R 2222:localhost:22 thedude@blackbox.example.com

Once you are into blackbox, you just need to stay logged in. I usually enter a command like:

thedude@blackbox:~$ while [ 1 ]; do date; sleep 300; done

to keep the machine busy. And minimize the window.
3. Now instruct your friends at tech to SSH as thedude into blackbox without using any special SSH flags. You’ll have to give them your password:

root@tech:~# ssh thedude@blackbox.example.com .
4. Once tech is on the blackbox, they can SSH to ginger using the following command:

thedude@blackbox:~$: ssh -p 2222 root@localhost
5. Tech will then be prompted for a password. They should enter the root password of ginger.

6. Now you and support from tech can work together and solve the problem. You may even want to use screen together! (See Trick 4.)

Source: IBM DeveloperWorks

PostgreSQL DBA Commands

In this article, We review top 15 practical postgreSQL DBA command examples.
Continue reading ‘PostgreSQL DBA Commands’

Upgrading openSUSE 10.3 –> 11.0 in a running system.

Upgrading openSUSE between releases while the system is running is not a currently supported method of upgrading. The supported method is to boot from an install medium and select the upgrade option. Nevertheless, it is possible to upgrade a running system. This is more difficult than normal with openSUSE 10.3 -> openSUSE 11.0 due to the change in RPM payload format from bz2 -> lzma which makes the RPM in 10.3 unable to install RPMs from 11.0.
Continue reading ‘Upgrading openSUSE 10.3 –> 11.0 in a running system.’

How to install Gentoo masked packages?

You can ask emerge to use the masked version available in portage by setting the variable ACCEPT_KEYWORDS to ACCEPT_KEYWORDS=”~x86″ before running the emerge command. It makes sense to set a command alias in roots .bashrc that goes alias aemerge=’ACCEPT_KEYWORDS=”~x86″ emerge’.
Continue reading ‘How to install Gentoo masked packages?’

Indenting selected lines

You can select lines by pressing V, then moving the cursor down or up (with j or k). After selecting lines, press > to increase the indent, or < to decrease it. Then press . to repeat the action, or u to undo it.
If you want the visual selection to be retained after pressing > or <, use these mappings:

:vnoremap > >gv
:vnoremap < <gv

An alternative for anyone using :behave mswin, is to select lines by holding down Shift and pressing the cursor down or up arrow keys. However, in select mode, if you press >, the selected text will be replaced with ‘>’. Instead, you can use Tab to increase the indent, and Shift-Tab to decrease it, with these mappings:

:vnoremap <Tab> >
:vnoremap <S-Tab> <

In select mode, visual-mode mappings temporarily set visual mode (:help Select-mode-mapping).Also, the select mode will be retained. You could use the following alternative if you want to exit from select mode after pressing Tab or Shift-Tab:

:vnoremap <Tab> >gV
:vnoremap <S-Tab> <gV