Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Reboot via telnet
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
guerro
Guru
Guru


Joined: 21 Jun 2004
Posts: 402
Location: Brescia

PostPosted: Fri Jan 13, 2006 8:43 am    Post subject: Reboot via telnet Reply with quote

Ciao a tutti,
avrei questo problemino, magari stupido, ma per me bloccante:

dovrei far fare il reboot ad una macchina a cui posso accedere da remoto solo tramite telnet, per cui i passaggi dovrebbero essere i seguenti:
1) connessione tramite telnet
2) invio del nome utente
3) invio della password
4) invio del comando di reboot
5) disconnessione telnet

Qualcuno saprebbe indicarmi come implementare uno scrippettino bash che faccia tutto questo?
Ho provato a cercare nel forum e su google, ma senza grandi risultati.
_________________
(.(*. .*).)
.. G u e r r o ..
(.(.* *.).)
Back to top
View user's profile Send private message
salade
Apprentice
Apprentice


Joined: 10 May 2004
Posts: 170

PostPosted: Fri Jan 13, 2006 8:50 am    Post subject: Re: Reboot via telnet Reply with quote

guerro wrote:

Qualcuno saprebbe indicarmi come implementare uno scrippettino bash che faccia tutto questo?

Un poco OT, cmq il tutto si può fare con un comando solo.
Questo link può aiutarti:
http://kmself.home.netcom.com/Linux/FAQs/sshrsakey.html

;)

EDIT: Che pisquano, davo per scontato che fosse ssh. sorry..


Last edited by salade on Fri Jan 13, 2006 8:54 am; edited 1 time in total
Back to top
View user's profile Send private message
mouser
Veteran
Veteran


Joined: 10 Aug 2004
Posts: 1419
Location: Milano

PostPosted: Fri Jan 13, 2006 8:52 am    Post subject: Reply with quote

Prova con expect..... si occupa proprio di questo, ovvero di sopperire all'input dell'utente tramite uno script in tck.
Dovrebbe essere fornito insieme ad uno scrippettino di nome autoexpect, che ti permette di derivare lo script dai tuoi comandi
In pratica i passaggi diventerebbero questi:
Code:
# autoexpect
Script started
# telnet nomemacchina
user: tuauser
pass: tuapassword
nomemacchina# reboot
nomemacchina# exit
# exit

E ti troverai lo scrippettino già pronto-pronto all'uso che ripete i tuoi passaggi; nota però che le password che vai ad inserire
risulteranno in chiaro nello script (anche se non credo per te sia un problema, se utilizzi telnet per collegarti in remoto...)

Ciriciao
mouser :wink:

[edit]
salade wrote:
... cmq il tutto si può fare con un comando solo ...

giaà, ma questo non si può inserire in uno script che esegue il reboot.... nel momento in cui l'autenticazione di ssh funziona, fisicamente ti trovi in un'altra shell, e quindi non sarà possibile per lo script lanciato in precedenza eseguire un comando in questa nuova (almeno, non che io sappia).
Certo, è sempre possibile, dopo aver eseguito l'howto da te consigliato, lanciare
Code:
# ssh utente@hostremoto "shutdown -r now"

Per eseguire il reboot "on-the-fly" 8)

ps: Per evitare di essere bacchettato dai mod, ti consiglio d'ora in poi, di evitare abbreviazioni (per esempio "cmq")... rimane anche più leggibile il forum :wink:


Last edited by mouser on Fri Jan 13, 2006 8:57 am; edited 1 time in total
Back to top
View user's profile Send private message
lavish
Bodhisattva
Bodhisattva


Joined: 13 Sep 2004
Posts: 4296

PostPosted: Fri Jan 13, 2006 8:57 am    Post subject: Reply with quote

Spostato da Forum italiano (Italian) a Forum di discussione italiano.
_________________
minimalblue.com | secgroup.github.io/
Back to top
View user's profile Send private message
salade
Apprentice
Apprentice


Joined: 10 May 2004
Posts: 170

PostPosted: Fri Jan 13, 2006 9:03 am    Post subject: Reply with quote

mouser wrote:

Per eseguire il reboot "on-the-fly" 8)

è proprio quello che intendevo, ma se si tratta di telnet non si può fare...

Quote:

ps: Per evitare di essere bacchettato dai mod, ti consiglio d'ora in poi, di evitare abbreviazioni (per esempio "cmq")... rimane anche più leggibile il forum :wink:

buh buh :cry: è l'unica abbreviazione che uso! ;)
Back to top
View user's profile Send private message
GiRa
l33t
l33t


Joined: 07 Apr 2005
Posts: 717

PostPosted: Fri Jan 13, 2006 9:54 am    Post subject: Reply with quote

hosts.equiv ed i suoi amici ;)
Back to top
View user's profile Send private message
richard77
Apprentice
Apprentice


Joined: 21 Apr 2004
Posts: 281

PostPosted: Fri Jan 13, 2006 10:07 am    Post subject: Reply with quote

Potresti creare un'utente con /sbin/halt come shell.
_________________
Fletto i muscoli e sono nel vuoto
Back to top
View user's profile Send private message
makoomba
Bodhisattva
Bodhisattva


Joined: 03 Jun 2004
Posts: 1856

PostPosted: Fri Jan 13, 2006 10:27 am    Post subject: Reply with quote

Code:
( echo root; sleep 1; echo password; sleep 1; echo reboot ; sleep 1 ) | telnet host

_________________
When all else fails, read the instructions.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum