Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon Linux fails with Error: Error: ioctl(2) failed. #83

Closed
russau opened this issue Mar 5, 2017 · 11 comments
Closed

Amazon Linux fails with Error: Error: ioctl(2) failed. #83

russau opened this issue Mar 5, 2017 · 11 comments

Comments

@russau
Copy link

russau commented Mar 5, 2017

wetty is working fine for me when I don't run as root and allow it to kick off ssh. When it runs as root on an Amazon Linux instance I see Error: ioctl(2) failed every time I attempt to connect.

I see the code is running /bin/login, when I ssh onto the instance and run login as root it kicks out my ssh session. Doing exactly the same thing on an Ubuntu Linux instance works fine. So I'm thinking there is something funny about the login configuration on Amazon Linux. I'm not really familiar enough with it to debug things beyond this. Would appreciate any help anyone can offer.

Thanks!
Russ

@aleschmid
Copy link

aleschmid commented Mar 11, 2017

Hi 😃

I was about to open another issue, but since this one is trying to solve which seems to be the same problem I'm just gonna write it here.

In my case, to start, like I already said I've the same problem; doesn't matter if I try to connect to 'localhost' or a remote server; the same message pops out at the Terminal: Error: ioctl(2) failed. On the other hand, I also get these messages on the browser depending on whether I run the program as 'root' or a regular user:

  • As regular user:

    ssh: connect to host localhost port 22: Connection refused

    Which I assume it's because the program hasn't been given the right permissions.

  • As root:

    execvp(3) failed.: No such file or directory

OS: macOS Sierra (10.12.3).

Haven't made any in-depth research though. In case I find any solution I'll post it asap!

Have a good day!

@russau
Copy link
Author

russau commented Mar 12, 2017

Hi @aleschmid,

I hit some similar issues. Looking at this line:

term = pty.spawn('ssh', [sshuser + sshhost, '-p', sshport, '-o', 'PreferredAuthentications=' + sshauth], {

Will give you an idea of the ssh command wetty is attempting. You can use --sshhost --sshport --sshuser to override the defaults.

If you don't pass any arguments wetty is running ssh localhost -p 22 -o PreferredAuthentications=password. Do you have ssh switched on on your mac? Some details here: https://support.apple.com/kb/ph18726?locale=en_US

Russ

@aleschmid
Copy link

Hi @russau! 😃

The first time I wrote the command I didn't have the SSH server up, so it failed as expected. However, 'cause I supected it could be the problem, I didn't even bother to turning it on, I just ran it again but this time pointing to my user at my website's server (using the parameters you mentioned except for the --sshport, because 22 is the default one) —I mentioned it briefly in the previous message:

…doesn't matter if I try to connect to 'localhost' or a remote server

Both times I got the very same message, which makes me think it's not an SSH problem but a compatibility issue with Mac. Besides, since you brought it up, I just tried going to Preferences and enabling that option in order to see if it was in fact my fault, but it logged-in perfectly through the Terminal's bash.

Have a nice day!

@lff0305
Copy link

lff0305 commented Jun 22, 2017

Exact the same issue on CentOS, if wetty is launched by root.
The reason is that the /usr/sbin/login on CentOS just simply logout and exit.

Comment the line of /bin /login works
// if (getPid() == 0) {
// fork /bin/login process
// } else {
Run ssh command
// }

@plato79
Copy link

plato79 commented Jul 4, 2017

just run it with "sudo -u < user > wetty". It will run in user space and will not launch /bin/login but ssh.. I had the same problem with FreeBSD, this solved the problem.

@khanzf
Copy link
Contributor

khanzf commented Sep 5, 2017

Figured out the issue on FreeBSD! Solution in a nutshell is two-fold:

If running as a non-root user:

  • Enable "PasswordAuthentication yes" in sshd.
  • Modify sshauth in wetty/app.js, currently line 45, from
    var sshauth = 'password';
    to:
    var sshauth = 'keyboard-interactive';

If running as root:

  • Change line 106 from:
    term = pty.spawn('/bin/login', [], {
    to
    term = pty.spawn('/usr/bin/env', ['login'], {

@superuzzo
Copy link

superuzzo commented Jul 21, 2018

Hi!
I've downloaded and installed the latest version, and all the suggested modifications at line 45 and 106 are already in place. However I'm experiencing the same issue on CentOs 7.
The process works like a charm if I run it as standard user, however when I run it as root, it does not work (it returns "Error: ioctl(2) failed" on console side, while on browser side there is a red cursor on the upper left corner, without any user/password prompt).
Any help will be appreciated.

Thanks!

@cedricfrancoys
Copy link

I had the same issue which was related to two factors:

  1. resizing when term is not ready : can be fixed with an additional test
    see pty.resize - ioctl failed. chjj/pty.js#187
  2. ssh was aborting with an exit code 6 : because of an extra prompt
    add these args to the command line to avoid this : '-o', 'StrictHostKeyChecking=no'

@butlerx
Copy link
Owner

butlerx commented Jan 5, 2019

running as root while the host is localhost has it use login rather then sshing ioctl is the login prompt exiting to early see here microsoft/node-pty#220

@simo735
Copy link

simo735 commented Mar 23, 2019

Exact the same issue on CentOS, if wetty is launched by root.
The reason is that the /usr/sbin/login on CentOS just simply logout and exit.

Comment the line of /bin /login works
// if (getPid() == 0) {
// fork /bin/login process
// } else {
Run ssh command
// }

@lff0305 I had the some issue on my centos, in which file exactly did you do this modification ?

@github-actions
Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants