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

Issues related to applications and software problems
Post Reply
User avatar
eugene.ievlev
Posts: 19
Joined: 2014/02/07 10:41:03
Location: Ukraine
Contact:

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

Post by eugene.ievlev » 2015/07/07 08:02:09

Dear team,

I have got really strange trouble.
System CentOS 7.
SELinux is disabled.

When I try use ssh via su -l username -c "ssh user@host" i got an error, but if i logged in by this user, from user console - all works... Maybe some one can help me.
Example:

Trying connect via ssh from root - OK :

Code: Select all

[root@ovh-backup ~]# ssh root@jump-dev.mydomain.biz
root@jump-dev.mydomain.biz's password:
Last login: Tue Jul  7 09:53:12 2015 from 213.169.85.87
CentOS release 6.5 (Final)
[root@jump-dev ~]#
Trying connect via ssh from user backuppc - OK :

Code: Select all

[root@ovh-backup ~]# su -l backuppc
Last login: Tue Jul  7 09:51:42 CEST 2015 on pts/0
-bash-4.2$ ssh root@jump-dev.mydomain.biz
root@jump-dev.mydomain.biz's password:
Last login: Tue Jul  7 09:53:47 2015 from ovh-backup.mydomain.biz
CentOS release 6.5 (Final)
[root@jump-dev ~]#
Trying login via su command - ERROR:

Code: Select all

[root@ovh-backup ~]# su -l backuppc -c "ssh -vvv root@jump-dev.mydomain.biz"
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to jump-dev.mydomain.biz [37.59.6.40] port 22.
debug1: Connection established.
debug1: identity file /var/lib/BackupPC/.ssh/id_rsa type -1
debug1: identity file /var/lib/BackupPC/.ssh/id_rsa-cert type -1
debug3: Incorrect RSA1 identifier
debug3: Could not load "/var/lib/BackupPC/.ssh/id_dsa" as a RSA1 public key
debug1: identity file /var/lib/BackupPC/.ssh/id_dsa type 2
debug1: identity file /var/lib/BackupPC/.ssh/id_dsa-cert type -1
debug1: identity file /var/lib/BackupPC/.ssh/id_ecdsa type -1
debug1: identity file /var/lib/BackupPC/.ssh/id_ecdsa-cert type -1
debug1: identity file /var/lib/BackupPC/.ssh/id_ed25519 type -1
debug1: identity file /var/lib/BackupPC/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "jump-dev.mydomain.biz" from file "/var/lib/BackupPC/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /var/lib/BackupPC/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: setup hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: setup hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 1551/3072
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 13:0a:2a:95:e2:a9:9a:97:de:4b:65:e3:78:08:92:41
debug3: load_hostkeys: loading entries for host "jump-dev.mydomain.biz" from file "/var/lib/BackupPC/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /var/lib/BackupPC/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "37.59.6.40" from file "/var/lib/BackupPC/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /var/lib/BackupPC/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'jump-dev.mydomain.biz' is known and matches the RSA host key.
debug1: Found key in /var/lib/BackupPC/.ssh/known_hosts:1
debug2: bits set: 1526/3072
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /var/lib/BackupPC/.ssh/id_rsa ((nil)),
debug2: key: /var/lib/BackupPC/.ssh/id_dsa (0xb622192dbb0),
debug2: key: /var/lib/BackupPC/.ssh/id_ecdsa ((nil)),
debug2: key: /var/lib/BackupPC/.ssh/id_ed25519 ((nil)),
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /var/lib/BackupPC/.ssh/id_rsa
debug3: no such identity: /var/lib/BackupPC/.ssh/id_rsa: No such file or directory
debug1: Offering DSA public key: /var/lib/BackupPC/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /var/lib/BackupPC/.ssh/id_ecdsa
debug3: no such identity: /var/lib/BackupPC/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /var/lib/BackupPC/.ssh/id_ed25519
debug3: no such identity: /var/lib/BackupPC/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: packet_send2: adding 64 (len 49 padlen 15 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: packet_send2: adding 64 (len 49 padlen 15 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug3: packet_send2: adding 64 (len 49 padlen 15 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
In logs - just one:

Code: Select all

Jul  7 09:57:12 ovh-backup su: pam_unix(su-l:session): session opened for user backuppc by root(uid=0)
Jul  7 09:57:14 ovh-backup su: pam_unix(su-l:session): session closed for user backuppc
I would be very grateful if you can halp me,
Thanks,
Eugene

giulix63
Posts: 1305
Joined: 2014/05/14 10:06:37
Location: UK

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

Post by giulix63 » 2015/07/07 09:35:28

You can't connect using interactive SSH if you don't have a terminal to read the password from. What exactly are you trying to achieve? If you need to connect via SSH without typing a password, you'll need RSA keys as explained here or here, but do use a passphrase and ssh-agent. Once you've done that, you can disable password authentication in SSH entirely, thus fortifying your installation. And disabling root in sshd_config is always a good idea. If the ultimate goal is to store backups remotely, you may get some ideas from my blog, too...
Root is evil: Do not use root (sudo) to run any of the commands specified in my posts unless explicitly indicated. Please, provide the necessary amount of context to understand your problem/question.

User avatar
eugene.ievlev
Posts: 19
Joined: 2014/02/07 10:41:03
Location: Ukraine
Contact:

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

Post by eugene.ievlev » 2015/07/07 10:50:51

Thanks for answer!
My fault... I used this method in gentoo... not in CentOS...
Clear. Thanks for info, giulix63.

Topic can be closed.

Post Reply