0

I have been using shelljs to execute certain set of commands. So i tried to connect to a remote ubuntu server over ssh via shelljs. This is my nodejs file.

var shelljs = require('shelljs');
shelljs.exec('ssh -i [path/to/pem/file] ubuntu@[taregt_ip]');

But i get this error:

Pseudo-terminal will not be allocated because stdin is not a terminal.

So how to solve this issue or is there any other utility to connect to ssh with one single command.

EDIT: the link you guys are posting for me to refer in not the duplicate of my problem.

1

1 Answer 1

1

SSH doesn't always allocate a pseudo-terminal. That is explained in this existing answer. You should add the -tt flag to force this.

That said, I wouldn't use shelljs to do ssh. As you are just executing a local binary, this solution a) is not portable and b) will not know how to parse errors or deal with unexpected output. I have used ssh2 in the past for similar projects, as it has an interactive SSH option, which makes it easy to create streams (STDOUT and STDIN) from an SSH connection.

Sign up to request clarification or add additional context in comments.

2 Comments

I have seen this link, but didn't find it useful. ssh2 seemed to the right choice but it throws this error. Timed out while waiting for handshake
@Satnam run it in verbose mode. I would imagine there is a problem with your SSL config, which is why both are giving you issues.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.