Saturday, May 24, 2014

SSH Agent Forwarding


Scenario

  • - Password login is disabled on both the servers Node1 and Node2
  • - Your public key is added to both the servers Node1 and Node2 when they were created. (for example using OpenStack)
  • - Firewall rules only allow access to Node1


Question
- How to login to Node2

Solution: Enable agent forwarding


  •  Add your ssh private key to ssh forwarding agent

 ssh-add -c  ~/.ssh/your_private_key

  •  ssh to Node1 by enabling agent forwarding, like so:

 ssh user@Node1 -A

  •  Once you login to Node1, you can login again to Node2

 ssh user@Node2

  •  You can combine both steps into 1 command like so

 ssh user@Node1 -A -t ssh user@Node2


Friday, January 3, 2014

VIM Chores

1. Read the output of a vim command (ex mode).
Say for example to list all the loaded plugins in vim

:redir @q 
:scriptnames
:redir end 

The output is now saved into q register. 
To paste from register q just type:

 "qp 

 The output is in vim now.

2. Read the output of a external command in vim
Say for example, i want to get the list of all processes in linux in vim

:read !ps -ef

and the processlist is now in the vim buffer.