Belier : script your SSH connection

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search
Belier

Software version 1.2
Operating System Debian 7
Website Belier Website
Last Update 06/05/2013
Others

1 Introduction

Belier[1] allows opening a shell or executing a command on a remote computer through a SSH connection. The main feature of Belier is its ability to cross several intermediate computers before realizing the job.

  • Belier reaches the final computer through intermediate machines.
  • You can execute commands with any account available on the remote computer.
  • It is possible to switch account on intermediate computers before accessing the final computer.
  • You can open a data tunnel through every host you cross to the final host.
  • Belier generates one script for each final computer to reach.

Belier aims to give a single system administrator a tool to work independently, without requiring to modify the computers he has to cross, just using the current configurations of every machines he has to work with. So it's not a revolutionary tool but it helps to be productive quickly.

For instance, here is what is possible to do with it :

Schema belier.png[2]

2 Installation

To install it, as usual it's easy on Debian :

Command aptitude
aptitude install belier

3 Configuration

The configuration is really simple. Type line by line in a 'connection' file, connection's informations to :

  1. The server name or IP
  2. The username
  3. The password

It should looks like this :

Configuration File ~/connection
server1_bound username password
server2_bound username password
server3_bound username password
final_server username password

Then generate an automatic script shell connection with Belier :

Command bel
bel -e ~/connection

You should now have a script containing all the commands to quickly connect to your wished server :

Configuration File final_server.sh
#!/usr/bin/expect -f
set timeout 10
 
spawn ssh -o NoHostAuthenticationForLocalhost=yes -o StrictHostKeyChecking=no  server1_bound
expect -re  "(%|#|\\$) $"
send -- "su - username\r"
expect ":"
send -- "password\r"
expect -re  "(%|#|\\$) $"
send -- "ssh -o NoHostAuthenticationForLocalhost=yes -o StrictHostKeyChecking=no  server2_bound\r"
expect -re  "(%|#|\\$) $"
send -- "su - username\r"
expect ":"
send -- "password\r"
expect -re  "(%|#|\\$) $"
send -- "ssh -o NoHostAuthenticationForLocalhost=yes -o StrictHostKeyChecking=no  server3_bound\r"
expect -re  "(%|#|\\$) $"
send -- "su - username\r"
expect ":"
send -- "password\r"
expect -re  "(%|#|\\$) $"
send -- "ssh -o NoHostAuthenticationForLocalhost=yes -o StrictHostKeyChecking=no  final_server\r"
expect -re  "(%|#|\\$) $"
send -- "su - username\r"
expect ":"
send -- "password\r"
expect -re  "(%|#|\\$) $"
interact +++ return

You can now launch the command with final_server.sh :-)

4 References

  1. ^ http://www.ohmytux.com/belier/
  2. ^ http://carlchenet.wordpress.com/?p=22