running a program through ssh fails with Error opening terminal: unknown.
A plain ssh
command like that does not have a tty
(terminal). Use the -t
option to force ssh
to open the terminal on its way in.
From the manual:
-t
Force pseudo-tty allocation. This can be used to execute arbitrary 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.
So this would work (better):
ssh -t servername '~/htopmem.sh'
Error opening terminal: unknown.' error when running a command in SSH server through Python
Your command needs terminal emulation.
Either:
Try to find if there's a way to run the command, so that it does not require the terminal emulation. Maybe
-bg
switch can help.Possibly this was a bug in an older version of SIPP. Make sure you have the latest version. See Startup failure when running from environment without TERM.
Or, enable the terminal emulation (what can bring unwanted side effects). With Paramiko
SSHClient.exec_command
, use itsget_pty
argument:stdin, stdout, stderr = self.client.exec_command(command, get_pty=True)
open terminal failed: missing or unsuitable terminal: unknown when running shell script from Java program
The problem is that you are attaching to an interactive tmux
session, where you need to have a terminal which supports cursor movement codes etc.
The easy workaround is to not attach; just submit the command you want to run into the session.
ssh -tt -i ~/.ssh/ssh-key.key opc@___._.___.___ tmux send-keys './run' C-m
This obviously requires that whatever is running inside the remote tmux
session is in a state where you can submit a shell command, i.e. at a shell prompt or similar. For robustness you might want to take additional measures to make sure this is always the case, or refactor your solution to avoid running inside tmux
e.g. by having the command redirect its output to a file where you can examine it from any terminal at any time (though this assumes you don't also need to interact with it subsequently).
Use watch over ssh
The watch
needs a PTY, which is not allocated when you add a command to ssh
. Use
ssh -t user@host "watch who"
nano error: Error opening terminal: xterm-256color
On Red Hat this worked for me:
export TERM=xterm
further info here: http://www.cloudfarm.it/fix-error-opening-terminal-xterm-256color-unknown-terminal-type/
Pseudo-terminal will not be allocated because stdin is not a terminal
Try ssh -t -t
(or ssh -tt
for short) to force pseudo-tty allocation even if stdin isn't a terminal.
See also: Terminating SSH session executed by bash script
From ssh manpage:
-T Disable pseudo-tty allocation.
-t Force pseudo-tty allocation. This can be used to execute arbitrary
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.
Error opening terminal: xterm-256color
Probably due to a Lion upgrade/install. Did you do that recently @Gih?
Possible duplicate (with fix) at
nano error: Error opening terminal: xterm-256color
EDIT:
Easiest fix (takes 10 seconds)...from Michael:
There is a solution much easier:
http://ricochen.wordpress.com/2011/07/23/mac-os-x-lion-terminal-color-remote-access-problem-fix/
Related Topics
How to Add External References in Monodevelop
Host Multiple ASP.NET Core Web Application Under a Single Linux Server
How to Run a Bash Function() in a Remote Host? in Ubuntu
Vim Pauses If Echo in .Vimrc File
Link Extraction from a Google Page in Bash
Can't Load Mod_Wsgi Compiled for Python 3
What Is The Analogue of an Ndis Filter in Linux
Bluetooth Over Uart Using Hciattach
Why Does Printf Still Work with Rax Lower Than The Number of Fp Args in Xmm Registers
Ftrace: System Crash When Changing Current_Tracer from Function_Graph via Echo
Reducing Privileges of a Process on Unix or Gnu/Linux
Inconsistent Systemd Startup of Freeswitch
Cvs Error: Failed to Create Lock Directory... Permission Denied
Bash Script Commands Not Working in Cron
How to Know If I Can Compile with Fma Instruction Sets