Inicio directamente un script/comando remoto en un servidor Ubuntu con el siguiente comando:
ssh me@server 'nano my_file.txt'
Sin embargo, esto arroja un error:
Error opening terminal: unknown.
Otro ejemplo, llamar a un script remoto que contiene el nano
comando anterior produce el mismo error.
ssh me@server 'open_nano.sh'
Cuando lo hago ssh me@server 'echo something'
, obtengo something
lo esperado.
¿Lo que está mal?
Respuesta1
Tendrías que usar la -t
bandera.
Ejemplos:
ssh -t me@server 'nano my_file.txt'
ssh -t me@server 'open_nano.sh'
Explicación de man ssh
:
-t Force pseudo-tty allocation. This can be used to execute arbi‐ trary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.