Skip to content

Instantly share code, notes, and snippets.

@celesteking
Last active February 21, 2020 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save celesteking/8c5fc9857cc20bff83466da7beb5b0d7 to your computer and use it in GitHub Desktop.
Save celesteking/8c5fc9857cc20bff83466da7beb5b0d7 to your computer and use it in GitHub Desktop.
Can't SSH out of gitlab/docker instance to remote host? "can't open /dev/tty: No such device or address"

Look no further! It's not a problem with you, it's a problem with SSH client. The issue is that your private key file is missing the trailing newline and ssh just can't understand that file thinking that it's been encrypted with a passprhase -- what a dork!

your debug output would be like this:

debug1: read_passphrase: can't open /dev/tty: No such device or address
debug2: no passphrase given, try next key

OR with strace -fx ssh-keygen -y -f KEY: Enter passphrase: Load key "KEY": incorrect passphrase supplied to decrypt private key

fstat(3, {st_mode=S_IFREG|0400, st_size=491, ...}) = 0
read(3, "-----BEGIN OPENSSH PRIVATE KEY--"..., 1024) = 491
read(3, "", 533)                        = 0
read(3, "", 1024)                       = 0
close(3)                                = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
open("/dev/tty", O_RDWR)                = -1 ENOENT (No such file or directory)

OR ssh complaining with:

Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).

So check your private SSH keyfile and make sure there's a newline at the end of file. Check it with ssh-keygen -y -f KEY, it should print the pubkey.

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