2015-04-13 15 views
23

ho alcuni alias per ssh, ad esempio:Come non passano locale tramite ssh

alias buildWork="ssh work '~/build_app'" 

Problema che ssh passano alcune variabili come $LC_CTYPE che causano errori, come prevenire che e utilizzare configurazioni di server.

+0

Non ho un modo per testare , ma '(unset LC_CTYPE; ssh .....)' potrebbe funzionare. Questo temporaneamente disinserirà LC_CTYPE in una sotto-shell (il '(...)') e quindi eseguirà il comando 'ssh ....'. In bocca al lupo. – shellter

risposta

45

Sembra che il client SSH sia configurato per inoltrare le impostazioni locali. È possibile evitare questo alterando la configurazione (il file globale è in genere /etc/ssh/ssh_config):

# comment out/remove the following line 
SendEnv LANG LC_* 

In alternativa, è possibile modificare la configurazione del server, modificando /etc/ssh/sshd_config sulla macchina remota (si noti la d in sshd_config) :

# comment out/remove the following line 
AcceptEnv LANG LC_* 
+0

Grazie per averlo spiegato! – tonix

+0

sei fantastico! – lloiacono

2

In breve:

$ touch ~/.ssh/config 
$ ssh -F ~/.ssh/config [email protected]_host 

Vedi this answer per i dettagli.

+0

Quello che ha fatto il trucco. la domanda è perché non sta prendendo la configurazione dell'utente ma quella globale? – crsuarezf

-3
 
    To stop sending Environment Variables via sftp 
    Tested on CENTOS 7 
- create file config in ~/xyzuser/.ssh/config 
- set permission to 600 ~/xyzuser/.ssh/config 
- Put the following content in the file 

    comment the below lines commented to disable env variables######### 

- Send locale-related environment variables 
     SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY 
     SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE 
     SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE 
     SendEnv XMODIFIERS 

    Running without the ~/xyzuser/.ssh/config 
    sftp -v [email protected] 
    -------------------truncated output-------- 
    debug1: Requesting [email protected] 
    debug1: Entering interactive session. 
    debug1: Sending environment. 
    debug1: Sending env LANG = en_US.UTF-8 
    debug1: Sending subsystem: sftp 

    Running with the ~/xyzuser/.ssh/config 

    sftp -v -F /home/xyzuser/.ssh/config [email protected] 

    ----truncated---------- 
    debug1: channel 0: new [client-session] 
    debug1: Requesting [email protected] 
    debug1: Entering interactive session. 
    debug1: Sending subsystem: sftp 
    Connected to destinationhost 
+1

In realtà, prova a rispondere alla domanda invece di incollare la copia. – iceman

0

risposta accettata è corretta, ma, se non si desidera modificare i file di configurazione, è possibile ignorare locale specifica sulla riga di comando

LC_TIME="en_US.UTF-8" ssh [email protected] 
Problemi correlati