This is particularly important for programs such as scp or rsync which use SSH for data transfer. This detailed description of how the SCP protocol works explains how the SCP protocol consists of a mixture of textual protocol messages and binary file data. The solution is to disable the translate newline to carriage return-newline with stty -onlcr. The 2 primary modes of ssh are interactive-login with a tty, and specified-command without a tty, because those were the exact capabilities of rlogin and rsh respectively.
So the defaults were decided before ssh was born. Combinations like "I wanna specify a command and get a tty" had to be accessed with new options. Be glad that at least we have that option now, unlike when we were using rsh. We didn't trade away any useful features to get encrypted connections. We got bonus features! This allows you to get a "shell" of sorts to the remote server. For servers that do not grant shell access but allow SSH i. Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered.
What is the benefit of not allocating a terminal in ssh? Ask Question. Asked 5 years, 3 months ago. Active 1 year, 10 months ago.
Viewed 55k times. Every once in a while I will do something like ssh user host sudo thing and I am reminded that ssh doesn't allocate a pseudo-tty by default. Owens Chas. Owens 2 2 gold badges 12 12 silver badges 24 24 bronze badges. It would enrich the question to understand what the problem is.
- SSH notes - dtobimelic.gq.
- transformer un fichier flac en mp3 mac?
- A Linux Tutorial for HPC;
Air There isn't a problem I was trying to fix. There was a choice in how ssh is implemented that I was trying to understand. The question is very clear and the answer by Andrew B addresses the question nicely. The answer can be summed up like this: running ssh -t always is bad because it can cause some commands to break in weird ways.
Whereas, running a command that needs a PTY without one results in a clear error message that you need a terminal. Owens Sep 24 '14 at There are many programs that will skip the step of prompting the user for input if there is no terminal present, and that's a good thing. It would cause scripts to hang unnecessarily otherwise. Your input will be sent to the remote server for the duration of the command. This includes control sequences.
While a Ctrl-c break would normally cause a loop on the ssh command to break immediately, your control sequences will instead be sent to the remote server.
ssh_config | Andrew's Blog
This results in a need to "hammer" the keystroke to ensure that it arrives when control leaves the ssh command, but before the next ssh command begins. You must then expend the additional effort of ensuring that this control code does not get assigned to your variables, particularly if you're going to insert that output into a database. There is also the risk that programs will assume they can render output that is not friendly for file redirection. If the STDOUT redirection is from the output of the ssh client and the there is a PTY associated with the remote end of the client, the remote programs cannot make such a distinction and you will end up with terminal garbage in your output file.
Redirecting output to a file on the remote end of the connection should still work as expected. Andrew B Andrew B One almost gets the impression that I've worked on a team that has done this At the scope covered by this answer, it's a great. But the question had a wider scope, essentially wanting to know ALL the differences what to expect. Crossfit We covered the topic of login shells vs.
Anthony Geoghegan Anthony Geoghegan 2, 1 1 gold badge 17 17 silver badges 31 31 bronze badges. That was a very interesting point that I hadn't considered, thanks for adding this answer! Also with option -T from manual. Per zanco's answer , you're not providing a remote command to ssh , given how the shell parses the command line. To solve this problem, change the syntax of your ssh command invocation so that the remote command is comprised of a syntactically correct, multi-line string. There are a variety of syntaxes that can be used. For example, since commands can be piped into bash and sh , and probably other shells too, the simplest solution is to just combine ssh shell invocation with heredocs:.
Also note that EOT is surrounded by single-quotes, so that bash recognizes the heredoc as a nowdoc , turning off local variable interpolation so that the command text will be passed as-is to ssh.
Another valid approach is to pass the multi-line remote command as a single string, using multiple layers of bash variable interpolation as follows:. The output of cat will be passed back into the capturing interpolated string. The single quotes ' surrounding EOT specifies that the heredoc should be parsed as a nowdoc , which is a special form of heredoc in which the contents do not get interpolated by bash, but rather passed on in literal format.
EOT terminates the nowdoc, resulting in a nowdoc temporary file being created and passed back to the calling cat command. The contents of the interpolated string will be passed back to ssh as a single command line argument, which ssh will interpret as the remote command to execute as user server. If you need to avoid using external tools like cat , and don't mind having two statements instead of one, use the read built-in with a heredoc to generate the SSH command:. I'm adding this answer because it solved a related problem that I was having with the same error message.
Problem : I had installed cygwin under Windows and was getting this error: Pseudo-terminal will not be allocated because stdin is not a terminal. Resolution : It turns out that I had not installed the openssh client program and utilities. Because of that cygwin was using the Windows implementation of ssh, not the cygwin version. The solution was to install the openssh cygwin package. The warning message Pseudo-terminal will not be allocated because stdin is not a terminal.
The effect is that the variables inside the here document will remain empty because they are defined only in the remote shell.
- Specific Invocation for this Question.
- pro tools 9.0.6 ilok emulator mac.
- Fix: Pseudo-terminal will not be allocated because stdin is not a terminal!
- wifi repeater instellen op mac?
- Post navigation.
And, last but not least, it would be no bad idea to check if the directories on the remote host were created successfully see: check if file exists on remote host with ssh. All relevant information is in the existing answers, but let me attempt a pragmatic summary :. DO pass the commands to run using a command-line argument : ssh jdoe server ' In short: passing commands via stdin is a mechanism that is at odds with ssh 's design and causes problems that must then be worked around.
Read on, if you want to know more. By default, these commands run unattended, in an non-interactive shell, without the use of a pseudo terminal option -T is implied , and the session automatically ends when the last command finishes processing. In the event that your commands require user interaction , such as responding to an interactive prompt, you can explicitly request the creation of a pty pseudo-tty , a pseudo terminal, that enables interacting with the remote session, using the -t option; e. Note that the interactive read prompt only works correctly with a pty, so the -t option is needed.
Using a pty has a notable side effect: stdout and stderr are combined and both reported via stdout ; in other words: you lose the distinction between regular and error output; e. In the absence of this argument, ssh creates an interactive shell - including when you send commands via stdin , which is where the trouble begins:.
Select a Web Site
For an interactive shell, ssh normally allocates a pty pseudo-terminal by default, except if its stdin is not connected to a real terminal. Sending commands via stdin means that ssh 's stdin is no longer connected to a terminal, so no pty is created, and ssh warns you accordingly : Pseudo-terminal will not be allocated because stdin is not a terminal. Even the -t option, whose express purpose is to request creation of a pty, is not enough in this case : you'll get the same warning. Somewhat curiously, you must then double the -t option to force creation of a pty: ssh -t -t Perhaps the rationale for requiring this very deliberate step is that things may not work as expected.
For instance, on macOS In a pinch, use -T , and provide the commands via stdin , with a trailing exit command, but note that if you also need interactive features, using -tt in lieu of -T may not work.
What is the fix on a Linux or Unix bash shell?
I don't know where the hang comes from, but redirecting or piping commands into an interactive ssh is in general a recipe for problems. It is more robust to use the command-to-run-as-a-last-argument style and pass the script on the ssh command line:. The pseudo-terminal message is because of your -t which asks ssh to try to make the environment it runs on the remote machine look like an actual terminal to the programs that run there.
Your ssh client is refusing to do that because its own standard input is not a terminal, so it has no way to pass the special terminal APIs onwards from the remote machine to your actual terminal at the local end. After reading a lot of these answers I thought I would share my resulting solution. If you still want a remote interactive prompt e.
I was having the same error under Windows using emacs What solved my problem was setting the "tramp-default-method" variable to "plink" and whenever I connect to a server I ommit the ssh protocol. You need to have PuTTY's plink. Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site the association bonus does not count.
Would you like to answer one of these unanswered questions instead? Learn more about Teams.