Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync exits with the message "stdin is not a tty"

Tags:

ssh

tty

rsync

I want to use rsync to my remote server for which I have SSH access. I use the following command:

rsync -e 'ssh -p 22222' -rtz --delete content_dir/ [email protected]:/home/user/public_html

After entering the command, it asks for the password for the remote location. When I type it, it exits with the message,

stdin: is not a tty

How do I supply the password to rsync? The method suggested should also work when I use it in a shell script.

like image 608
Prasanna Natarajan Avatar asked Aug 15 '11 07:08

Prasanna Natarajan


3 Answers

You need to add:

[ -z "$PS1" ] && return

to the beginig of .bashrc that is located in your home dir.

like image 75
Josh C Josh C Avatar answered Nov 18 '22 09:11

Josh C Josh C


The password is being accepted here, as you've stated yourself the operation does happen.

The error message "stdin: is not a tty" is due to something in the startup script on your server attempting to process an action that should only happen for interactive logins (when you connect with ssh direct to the server, etc).

like image 29
Zoe J Hendrickse Avatar answered Nov 18 '22 09:11

Zoe J Hendrickse


[ -z "$PS1" ] && return solves the problem but it checks whether the prompt string length equals to zero and if it does then exits. Although $PS1 will not be set in a non-interactive shell, $PS1 being of zero length doesn't ultimately mean that the shell is not interactive.

Better approach is to check the shell's current options using $-. For example [[ $- != *i* ]] && return.

like image 1
Boris D. Teoharov Avatar answered Nov 18 '22 09:11

Boris D. Teoharov