Howtos
Information file syntax
[user@]host[:port] [pass|user [pass]] [-c|-t|-ot]
Open a remote shell as root
Howto
We first write a file named “connections” with the following line which defines information to access the final host:
admin@host Ic4r3 root jkw!po12;
Belier generates the script :
$ bel --entree=connections
$ ls
connections host.sh
Execution of the script (only the script is executed here, the other lines are self-generated) :
user@localhost:~$ ./host.sh
spawn ssh host
admin@host's password:
admin@host:~$ su - root
Password:
root@host:~#
Details
Let’s be more verbose about this example :
- We write a file with the mandatory information to connect the remote computer. The first field is composed by a login followed by ’@’ and the hostname (could be an ip address). You can omit the login and in this case, the actual login of your shell session will be used.
- The second field is a password to access the remote computer. It could be omitted if you exchanged ssh keys between the both computers.
- The third field is the login you want to switch to after beeing connected to the remote computer. It could be omitted if you don’t need to switch.
- The fourth and last field is the required password for the user switching. Could be omitted too.
- You generate the connection script. You could use standard input but in our example we use –entree option to pinpoint the information file.
- You launch the script and you reach the final computer.
Open a remote shell with several intermediate computers
Howto
We first write a file named “connections” with the following lines which defines information to access the final host:
middlehost1 admin azer0;lp!Z
admin@middlehost2
admin@lasthost root jkw!po12;
Belier generates the script:
$ bel --entree=connections
$ ls
connections lasthost.sh
Execution of the script (only the script is executed here, the other lines are self-generated):
user@localhost:~$ ./lasthost.sh
spawn ssh middlehost1
user@middlehost1's password:
user@middlehost1:~$ su - admin
Password:
admin@middlehost1:~$ ssh admin@middlehost2
admin@middlehost2:~$ ssh admin@lasthost
admin@lasthost's password:
admin@lasthost:~$ su - root
Password:
root@lasthost:~#
Details
Let’s be more verbose about this example:
- The first line of the information file defines the first intermediate computer to reach. On this one we also define a user switch.
- The second line defines the second intermediate computer.
- The third line defines the final computer. On this computer we switch to root.
- You generate the connection script. You could use standard input but in our example we use –entree option to pinpoint the information file.
- You launch the script and you reach the final computer.
Execute a command on a remote computer as root
Howto
We first write a file named “connections” with the following lines which defines information to access the final host:
middlehost admin azer0;lp!Z
admin@lasthost root !ZuP3r; -c
df -h
Belier generates the script :
$ bel --entree=connections
$ ls
connections lasthost.sh
Here is the output of the execution of the generated script :
user@localhost:~$ ./lasthost.sh
spawn ssh middlehost
user@middlehost's password:
user@middlehost:~$ su - admin
Password:
admin@middlehost:~$ ssh admin@lasthost
admin@lasthost's password:
admin@lasthost:~$ su - root
Password:
root@lasthost:~# df -h
Sys. de fich. Tail. Occ. Disp. %Occ. Monté sur
/dev/sda2 453G 61G 393G 14% /
varrun 2,0G 112K 2,0G 1% /var/run
varlock 2,0G 0 2,0G 0% /var/lock
udev 2,0G 48K 2,0G 1% /dev
devshm 2,0G 24K 2,0G 1% /dev/shm
lrm 2,0G 36M 1,9G 2% /lib/modules/2.6.24-21-generic/volatile
root@lasthost:~#
Details
Let’s be more verbose about this example :
- The first line of the information file defines the first intermediate computer to reach. On this one we also define a user switch.
- The second line defines the second intermediate computer.
- The third line defines the final computer. On this computer we switch to root.
- The fourth line defines the command we want to execute on the final computer.
- You generate the connection script. You could use standard input but in our example we use –entree option to pinpoint the information file.
- You launch the script and you reach the final computer.
Open a tunnel for data while connecting to a host
Howto
We want to send a big file through several hosts. Copying it through the different hosts would be painful. Bélier offers an elegant solution to solve that case by opening on your source computer a network port sending data directly on the final machine you want to work on. By default this network port has the following number : 9999.
We first write a file named “connections” with the following lines which defines information to access the final host:
middlehost azer0;lp!z -t
admin@lasthost root jkw!po12;
Belier generates the script :
$ bel --entree=connections
$ ls
connections lasthost.sh
Details
Let’s be more verbose about this example :
- That’s a pretty common order file but you have at the end of the line the -t (for tunnel) option, which means you want a data tunnel to this machine.
- That’s pretty much what you need. executing this script you’ll connect and open a shell on the final host, as usual.
- But moreover, you have on your source host an open port allowing you to send data directly to the final host, using the scp command.
Execution of the script (only the script is executed here, the other lines are self-generated) :
user@localhost:~$ ./lasthost.sh
user@middlehost's password:
user@middlehost:~$ ssh admin@lasthost
admin@lasthost:~$ su - root
password:
root@lasthost:~#
And now, leave this shell alone (don’t close it or you’ll lose the connection) and in a new one you’ll use the scp command:
user@localhost:~$ scp -P 9999 my-big-file.iso root@127.0.0.1:~
root@127.0.0.1's password:
toto 100% 19 0.0kb/s 00:00
user@localhost:~$
Your file has been successfully sent through every computers you usually have to cross! And you can use every command you want through this port, e.g ftp, rsync, whatever.
Open a tunnel for data with a specified port number while connecting to a host
Howto
We want to send a big file through several hosts. Copying it through the different hosts would be painful. Bélier offers an elegant solution to solve that case by opening on your source computer a network port sending data directly on the final machine you want to work on. By default this network port has the following number : 9999. lets take the following order file :
We first write a file named “connections” with the following lines which defines information to access the final host:
middlehost azer0;lp!z -ot
8888 7777
admin@lasthost root jkw!po12;
Belier generates the script :
$ bel --entree=connections
$ ls
connections lasthost.sh
Execution of the script (only the script is executed here, the other lines are self-generated) :
user@localhost:~$ ./lasthost.sh
user@middlehost's password:
user@middlehost:~$ ssh admin@lasthost
admin@lasthost:~$ su - root
password:
root@lasthost:~#
And now, leave this shell alone (don’t close it or you’ll lose the connection) and in a new one you’ll use the scp command:
user@localhost:~$ scp -P 8888 my-big-file.iso root@127.0.0.1:~
root@127.0.0.1's password:
toto 100% 19 0.0kb/s 00:00
user@localhost:~$
Your file has been successfully sent through every computer you usually have to cross! And you can use every command you want through the port you want to use, e.g ftp, rsync, whatever.
Details
Let’s be more verbose about this example :
- That’s a pretty common order file but you have at the end of the line the -ot (for tunnel options) option, which means you want a data tunnel to this machine.
- On the line following the one finishing by -ot you have to give to arguments: the local port you want to use and the remote port which is going to be opened.
- That’s pretty much what you need. Executing this script you’ll connect and open a shell on the final host, as usual.
- But moreover, you have on your source host an open port allowing you to send data directly to the final host, using the scp command.
Useful to know with passwords in Belier
If one of your passwords in the information file has a space in it, you need to wrap your password between quotation marks (character “) :
admin@serveur "My Passw0rd "
If one of your passwords in the information file has a quotation mark in it, you need to put a backslash before (character ) :
admin@serveur "My \"Pass word "