4

I directly start a remote script/command on an Ubuntu server with the following command:

ssh me@server 'nano my_file.txt'

However, this throws an error:

Error opening terminal: unknown.

Another example, calling a remote script which contains the nano command from above gives the same error.

ssh me@server 'open_nano.sh'

When I do ssh me@server 'echo something', I get something as expected.

What is wrong?

user1251007
  • 1,131

1 Answers1

9

You would have to use the -t flag.

Examples:

 ssh -t me@server 'nano my_file.txt'
 ssh -t me@server 'open_nano.sh'

Explanation from 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.
user1251007
  • 1,131