2012-08-28 14:29:59 +0000 2012-08-28 14:29:59 +0000
273
273
Advertisement

Come si esce da una connessione SSH?

Advertisement

Mi connetto ad un server via SSH per inviare un messaggio ad un socket server usando un comando come:

ssh 181.169.1.2 -p 5566

Dopo che la connessione è stabilita e scrivo il messaggio e lo invio non posso uscire dalla modalità testo. Posso solo inserire altro testo e questo è tutto.

C'è un comando o una combinazione di tasti che mi permette di tornare in modalità comando?

Advertisement

Risposte (7)

294
294
294
2013-07-17 09:26:09 +0000

Risposta breve: Digitare exit

Se questo non funziona, tuttavia…

SSH Escape Character e Disconnect Sequence

La maggior parte delle implementazioni SSH implementa un carattere di escape per sessioni interattive, simile alla combinazione di telnet Ctrl-]. Il carattere di escape SSH predefinito è ~, inserito all'inizio di una riga.

Se si vuole terminare una sessione interattiva OpenSSH ** che è bloccata e non può essere abbandonata inserendo exit o CtrlD in una shell sul lato remoto** , si può inserire ~ seguito da un punto .. Per essere sicuri di inserire il carattere di escape all'inizio di una riga di input, si deve premere prima Enter. Così la seguente sequenza terminerà nella maggior parte dei casi una sessione SSH:

Enter~.

Altre sequenze di escape

OpenSSH, per esempio, offre altre sequenze di escape oltre a ~.. L'immissione di ~? durante una sessione dovrebbe fornire un elenco. Alcuni esempi:

  • ~ - Ctrl-Z seguito ~& sospende la sessione,
  • ~# la mette direttamente in background,
  • ~~ fornisce un elenco delle connessioni inoltrate in questa sessione.
  • Se si vuole semplicemente inserire una tilde all'inizio di una riga, bisogna raddoppiarla: -e.

Il carattere di escape può essere cambiato usando l'opzione della riga di comando -e none. Se si imposta il valore speciale -e, l'escape è disabilitato e la sessione è completamente trasparente.

Vedere anche la pagina man di OpenBSD man su ssh (a cui si fa riferimento da www.openssh.org ) sotto l'opzione della riga di comando &007

195
195
195
2017-09-16 21:57:26 +0000

Come si esce da una connessione SSH?

Due modi:

  • chiudendo la sessione shell, ad esempio con exit seguito da Invio, o Ctrl-d di solito permette di uscire dalla sessione ssh normalmente,
  • nel caso in cui si ha una cattiva connessione e la shell non risponde, premere il tasto Invio, poi digitare ~. e ssh dovrebbe chiudere immediatamente e tornare al prompt dei comandi.

La prima opzione dovrebbe essere intuitiva, ma come facciamo a conoscere la seconda opzione?

Potremmo imparare queste informazioni da un'attenta lettura della pagina man.

$ man ssh

ci fornisce la documentazione SSH , che ha la seguente sezione sui caratteri di fuga:

ESCAPE CHARACTERS
     When a pseudo-terminal has been requested, ssh supports a number of
     functions through the use of an escape character.

     A single tilde character can be sent as ~~ or by following the tilde by
     a character other than those described below. The escape character
     must always follow a newline to be interpreted as special. The escape
     character can be changed in configuration files using the EscapeChar
     configuration directive or on the command line by the -e option.

     The supported escapes (assuming the default ‘~’) are:

     ~. Disconnect.

     ~^Z Background ssh.

     ~# List forwarded connections.

     ~& Background ssh at logout when waiting for forwarded connection
             / X11 sessions to terminate.

     ~? Display a list of escape characters.

     ~B Send a BREAK to the remote system (only useful if the peer sup‐
             ports it).

     ~C Open command line. Currently this allows the addition of port
             forwardings using the -L, -R and -D options (see above). It
             also allows the cancellation of existing port-forwardings with
             -KL[bind_address:]port for local, -KR[bind_address:]port for
             remote and -KD[bind_address:]port for dynamic port-forwardings.
             !command allows the user to execute a local command if the
             PermitLocalCommand option is enabled in ssh_config(5). Basic
             help is available, using the -h option.

     ~R Request rekeying of the connection (only useful if the peer
             supports it).

     ~V Decrease the verbosity (LogLevel) when errors are being written
             to stderr.

     ~v Increase the verbosity (LogLevel) when errors are being written
             to stderr.
32
Advertisement
32
32
2012-08-28 18:37:35 +0000

Vuoi uscire dal guscio SSH?

Puoi digitare exit e premere Invio, oppure usare Ctrl+D

11
11
11
2014-04-14 15:00:24 +0000

Basta digitare exit o logout (poi premere Invio, naturalmente) entrambi funzioneranno.

8
Advertisement
8
8
2016-06-14 22:26:47 +0000

Questi sono i personaggi supportati che forniscono varie opzioni con cui si può giocare con ssh.

Sequenze di escape supportate:

~. - terminate session

 ~B - send a BREAK to the remote system

 ~R - Request rekey (SSH protocol 2 only)

 ~# - list forwarded connections

 ~? - this message

 ~~ - send the escape character by typing it twice

(Si noti che le escape vengono riconosciute solo immediatamente dopo una nuova linea.) È possibile chiudere la lista delle sequenze di escape premendo Invio.

3
3
3
2013-07-17 07:12:49 +0000

È possibile scrivere logout nella riga della console (e premere Invio, naturalmente).

1
Advertisement
1
1
2018-03-29 17:25:28 +0000

MacOS : quando ssh si blocca utilizzare la seguente sequenza:

ENTER 
SHIFT+`
.

dove: shift+` produce ~ (carattere tilde)

Advertisement
Advertisement