Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

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.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.