Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Friday, August 1, 2008

Fixing tsocks 1.8 Beta

I was trying to use tsocks 1.8 beta5 on Fedora 8. After installing
I was able to use it. But, on next day, what I found is: I was not
able to access any website, messenger service. Although, I was
able to ping websites. Then I realized the tsocks is interfering
with direct connection to Internet. I was not using ssh tunnel at
that moment.

I have created patch for Makefile and tsocks script.

$ vi patch_Makefile

5c5

< prefix=/usr

---

> prefix=/usr/local

9c9

< libdir = /lib

---

> libdir = ${prefix}/lib

31c31

< CFLAGS = -g -O2 -Wall

---

> CFLAGS = -O3 -Wall



$ vi patch_tsocks
6c6

< # /usr/bin/tsocks program [program arguments...]

---

> # $PREFIX/bin/tsocks program [program arguments...]

13c13

< # /usr/bin/tsocks telnet www.foo.org

---

> # $PREFIX/bin/tsocks telnet www.foo.org

20c20

< # . /usr/bin/tsocks on

---

> # . $PREFIX/bin/tsocks on

22c22

< # . /usr/bin/tsocks off

---

> # . $PREFIX/bin/tsocks off

26c26

< # source /usr/bin/tsocks on

---

> # source $PREFIX/bin/tsocks on

28c28

< # source /usr/bin/tsocks off

---

> # source $PREFIX/bin/tsocks off

33c33

< # /usr/bin/tsocks

---

> # $PREFIX/bin/tsocks

39a40,41

> PREFIX="/usr/local"

>

49c51

< export LD_PRELOAD="/usr/lib/libtsocks.so"

---

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so"

51,52c53,54

< echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \

< export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD"

---

> echo $LD_PRELOAD | grep -q "$PREFIX/lib/libtsocks\.so" || \

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so $LD_PRELOAD"

56c58

< export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/usr\/lib\/libtsocks.so \?//'`

---

> export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\$PREFIX\/lib\/libtsocks.so \?//'`

71c73

< export LD_PRELOAD="/usr/lib/libtsocks.so"

---

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so"

73,74c75,76

< echo $LD_PRELOAD | grep -q "/usr/lib/libtsocks\.so" || \

< export LD_PRELOAD="/usr/lib/libtsocks.so $LD_PRELOAD"

---

> echo $LD_PRELOAD | grep -q "$PREFIX/lib/libtsocks\.so" || \

> export LD_PRELOAD="$PREFIX/lib/libtsocks.so $LD_PRELOAD"


How to apply patch and install tsocks?

$ tar -zxvf tsocks-1.8beta5.tar.gz


$ cd tsocks-1.8


$ ./configure


$ patch Makefile < patch_Makefile

$ patch tsocks < patch_tsocks


$ make


$ sudo make install


PS: If you do not find patches working, please mail me
at mitesh[dot]singh[dot]jat[at]gmail[dot]com . I will
send both patches to you.

Thursday, July 10, 2008

Password-less SSH for Batch Processing

1. Generation of Public-Private RSA key pair.

$ mkdir -p ~/.ssh
$ cd ~/.ssh
$ ssh-keygen -f keyname-identity -P '' -t rsa1

2. Allowing Password less Login on remote-machine.

Copy your public key on remote-machine.
$ scp keyname-identity.pub remote-machine:./.ssh/authorized_keys

Edit authorized_keys on remote-machine
Please place this line before your public key
in the authorized_keys file content
from="local_machine",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="remote_command_you_want_to_execute_on_local-machine"

For example:

from="local-machine",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="ls -la" 2048 35 1383...

3. Please make your private key secure.

$ chmod 511 ~/.ssh
$ chmod 400 ~/.ssh/keyname-identity

!! Caution !!

Putting a password less key in a file is exactly like writing a password on a piece of paper. A person who can access to your key file can do whatever you can do with the key.