Can’t open /dev/tty: No such device or address Error (Linux)

Symptoms

1. When attempting a command which requires input from the console the following error could occur:

can't open /dev/tty: No such device or address

2. When attempting to ssh the following error is given, even when SSHing to localhost:

Host key verification failed.
When running ssh -vvv user@localhost the exact debug line relating to this issue is: debug1: read_passphrase: can't open /dev/tty: No such device or address.

3. SFTP fails with the following error in auth.log:

error: open /dev/tty failed - could not set controlling tty: No such file or directory

Cause

The /dev/tty ‘special file’ has been removed.

Solution

mknod -m 644 /dev/tty c 5 0

This creates /dev/tty but only allows root to use it, run chmod a+rw /dev/tty

from http://ben.goodacre.name/tech/Can%27t_open_/dev/tty:_No_such_device_or_address_Error_%28Linux%29