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

Scripting with mosh #929

Closed
Ekleog opened this issue Oct 3, 2017 · 3 comments
Closed

Scripting with mosh #929

Ekleog opened this issue Oct 3, 2017 · 3 comments

Comments

@Ekleog
Copy link

Ekleog commented Oct 3, 2017

Hello,

I'm trying to run borgbackup over mosh instead of ssh, so that I don't have to manually restart the backup every time it is interrupted by a network failure.

I have tried disabling everything that makes mosh different from ssh that I could find in the man page, but still can't get it to work.

The issue (I think) I'm currently hitting is the difference in behaviour between ssh myserver -- cat and MOSH_TITLE_NOPREFIX=1 mosh --no-init --no-ssh-pty --predict=never -- cat (which I hoped would make mosh's UI close to ssh). Indeed, despite all these options, mosh still seems to put the terminal in alternate screen mode and to start with an empty newline.

I tried working around at least the spurious newline by piping into | tail -n +3, but I then get Remote: tcgetattr: Inappropriate ioctl for device when trying this in borgbackup -- I guess because there is no PTY associated with the command in this last case?

I run mosh 1.2.6 on the server and 1.3.2 on the client.

Would you happen to know of a work-around? If no, do you think this could easily be fixed? (I guess it's mostly disabling things mosh does for the end-user, but don't know anything about your codebase)

Thanks for your work on mosh!
Leo

@eminence
Copy link
Member

eminence commented Oct 3, 2017

If you are piping data to/from your ssh myserver -- cat command, then there is a fundamental difference between mosh and ssh that will make this not work.

While ssh can provide a reliable byte stream, mosh doesn't do this -- mosh only provides a terminal. To demonstrate the difference, consider what happens when you run ssh myserver -- cat /large_file.txt -- the entire contents of large_file.txt will be sent over the ssh connection and displayed on your local terminal.

But if you did the same with mosh: mosh my server -- cat /large_file.txt -- the entire file will be displayed to a remote terminal managed by mosh-server, and screenshots of that terminal will be sent to your local mosh-client, as fast as the network will allow. If you are on a very slow network, perhaps only the final page of output will be sent to the client.

Finally, because mosh is maintaining its own terminal on the client, there is no way for mosh to blindly dump incoming state to the outer terminal. mosh only really works for interactive terminals.

Does this explanation help?

@Ekleog
Copy link
Author

Ekleog commented Oct 3, 2017

Oh. Yes, it does. So I guess that's also the reason why there is no solution to #41 yet... and I also guess once it's solved it'd be quite easy to add an option for triggering the SSH-like mode.

Your pick whether to keep this issue open, then, I guess :)

Thanks for the explanation!

@eminence
Copy link
Member

eminence commented Oct 3, 2017

Yes, that's related, as well as #720 and the other issues that involve reliable byte streams.

Since this topic is covered by other issues, I'm going to close this issue.

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

No branches or pull requests

2 participants