I'm a bit at my wits end with this one. I'm seeing a problem where an automated script fails if it doesn't have a tty. Stripping it right back, the issue is that (open)ssh to a Windows build box VM succeeds if openssh has a controlling pty, and fails if it doesn't. IE: ssh -T host command succeeds ssh -tt host command succeeds nohup ssh -T host command fails nohup ssh -tt host command fails I'm running under 'env -i' to clear the environment off. I have verified the MS end is not actually running the command (as opposed to merely the output not showing) - for one it's 100 times quicker without nohup. I'm running: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014 -- Alex Bligh $ rm -f nohup.out; env -i nohup ssh -vvv -T -oGSSAPIAuthentication=no -oUserKnownHostsFile=unixbuild/known_hosts -oNumberOfPasswordPrompts=0 -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i build/protkey -p 10037 Administrator at 127.0.0.1 'powershell /c echo hello' ; cat nohup.out nohup: ignoring input and appending output to 'nohup.out' OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to 127.0.0.1 [127.0.0.1] port 10037. debug1: Connection established. debug3: Incorrect RSA1 identifier debug3: Could not load "build/protkey" as a RSA1 public key debug1: identity file build/protkey type 1 debug1: identity file build/protkey-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.4.3 debug1: no match: WeOnlyDo 2.4.3 debug2: fd 3 setting O_NONBLOCK debug3: put_host_port: [127.0.0.1]:10037 debug3: load_hostkeys: loading entries for host "[127.0.0.1]:10037" from file "unixbuild/known_hosts" debug3: load_hostkeys: found key type RSA in file unixbuild/known_hosts:12 debug3: load_hostkeys: loaded 1 keys debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01 at openssh.com,ssh-rsa-cert-v00 at openssh.com,ssh-rsa debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: curve25519-sha256 at 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 at openssh.com,ssh-rsa-cert-v00 at openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01 at openssh.com,ecdsa-sha2-nistp384-cert-v01 at openssh.com,ecdsa-sha2-nistp521-cert-v01 at openssh.com,ssh-ed25519-cert-v01 at openssh.com,ssh-dss-cert-v01 at openssh.com,ssh-dss-cert-v00 at 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 at openssh.com,aes256-gcm at openssh.com,chacha20-poly1305 at openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc at lysator.liu.se debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm at openssh.com,aes256-gcm at openssh.com,chacha20-poly1305 at openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc at lysator.liu.se debug2: kex_parse_kexinit: hmac-md5-etm at openssh.com,hmac-sha1-etm at openssh.com,umac-64-etm at openssh.com,umac-128-etm at openssh.com,hmac-sha2-256-etm at openssh.com,hmac-sha2-512-etm at openssh.com,hmac-ripemd160-etm at openssh.com,hmac-sha1-96-etm at openssh.com,hmac-md5-96-etm at openssh.com,hmac-md5,hmac-sha1,umac-64 at openssh.com,umac-128 at openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160 at openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5-etm at openssh.com,hmac-sha1-etm at openssh.com,umac-64-etm at openssh.com,umac-128-etm at openssh.com,hmac-sha2-256-etm at openssh.com,hmac-sha2-512-etm at openssh.com,hmac-ripemd160-etm at openssh.com,hmac-sha1-96-etm at openssh.com,hmac-md5-96-etm at openssh.com,hmac-md5,hmac-sha1,umac-64 at openssh.com,umac-128 at openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160 at openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,zlib at openssh.com,zlib debug2: kex_parse_kexinit: none,zlib at 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: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-cbc,aes128-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc at lysator.liu.se,cast128-cbc debug2: kex_parse_kexinit: aes128-cbc,aes128-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc at lysator.liu.se,cast128-cbc debug2: kex_parse_kexinit: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,none debug2: kex_parse_kexinit: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,none debug2: kex_parse_kexinit: none,none debug2: kex_parse_kexinit: none,none 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: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: RSA f3:0e:1c:c8:14:c9:11:b1:f4:6a:a3:4b:8d:66:0b:f7 debug3: put_host_port: [127.0.0.1]:10037 debug3: put_host_port: [127.0.0.1]:10037 debug3: load_hostkeys: loading entries for host "[127.0.0.1]:10037" from file "unixbuild/known_hosts" debug3: load_hostkeys: found key type RSA in file unixbuild/known_hosts:12 debug3: load_hostkeys: loaded 1 keys debug1: Host '[127.0.0.1]:10037' is known and matches the RSA host key. debug1: Found key in unixbuild/known_hosts:12 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: build/protkey (0x7ff216a52da0), explicit debug1: Authentications that can continue: password,gssapi-with-mic,publickey debug3: start over, passed a different list password,gssapi-with-mic,publickey debug3: preferred publickey,keyboard-interactive debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: build/protkey debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 535 debug2: input_userauth_pk_ok: fp 94:64:fc:54:e6:91:82:ee:c4:4e:ae:bd:cd:15:36:fa debug3: sign_and_send_pubkey: RSA 94:64:fc:54:e6:91:82:ee:c4:4e:ae:bd:cd:15:36:fa debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). Authenticated to 127.0.0.1 ([127.0.0.1]:10037). debug2: fd 4 setting O_NONBLOCK debug2: fd 5 setting O_NONBLOCK debug3: fd 6 is O_NONBLOCK debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Entering interactive session. debug2: callback start debug2: fd 3 setting TCP_NODELAY debug3: packet_set_tos: set IP_TOS 0x08 debug2: client_session2_setup: id 0 debug1: Sending environment. debug1: Sending command: powershell /c echo hello debug2: channel 0: request exec confirm 1 debug2: callback done debug2: channel 0: open confirm rwindow 131072 rmax 98304 debug2: channel 0: read<=0 rfd 4 len -1 debug2: channel 0: read failed debug2: channel 0: close_read debug2: channel 0: input open -> drain debug2: channel 0: ibuf empty debug2: channel 0: send eof debug2: channel 0: input drain -> closed debug2: channel_input_status_confirm: type 99 id 0 debug2: exec request accepted on channel 0 debug2: channel 0: rcvd adjust 0 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug2: channel 0: rcvd close debug2: channel 0: output open -> drain debug3: channel 0: will not send data after close debug2: channel 0: obuf empty debug2: channel 0: close_write debug2: channel 0: output drain -> closed debug2: channel 0: almost dead debug2: channel 0: gc: notify user debug2: channel 0: gc: user detached debug2: channel 0: send close debug2: channel 0: is dead debug2: channel 0: garbage collecting debug1: channel 0: free: client-session, nchannels 1 debug3: channel 0: status: The following connections are open: #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1) debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK debug3: fd 2 is not O_NONBLOCK Transferred: sent 4128, received 1912 bytes, in 0.0 seconds Bytes per second: sent 406787.3, received 188415.0 debug1: Exit status 0 $ env -i ssh -vvv -T -oGSSAPIAuthentication=no -oUserKnownHostsFile=unixbuild/known_hosts -oNumberOfPasswordPrompts=0 -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i build/protkey -p 10037 Administrator at 127.0.0.1 'powershell echo hello' OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to 127.0.0.1 [127.0.0.1] port 10037. debug1: Connection established. debug3: Incorrect RSA1 identifier debug3: Could not load "build/protkey" as a RSA1 public key debug1: identity file build/protkey type 1 debug1: identity file build/protkey-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.4.3 debug1: no match: WeOnlyDo 2.4.3 debug2: fd 3 setting O_NONBLOCK debug3: put_host_port: [127.0.0.1]:10037 debug3: load_hostkeys: loading entries for host "[127.0.0.1]:10037" from file "unixbuild/known_hosts" debug3: load_hostkeys: found key type RSA in file unixbuild/known_hosts:12 debug3: load_hostkeys: loaded 1 keys debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01 at openssh.com,ssh-rsa-cert-v00 at openssh.com,ssh-rsa debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: curve25519-sha256 at 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 at openssh.com,ssh-rsa-cert-v00 at openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01 at openssh.com,ecdsa-sha2-nistp384-cert-v01 at openssh.com,ecdsa-sha2-nistp521-cert-v01 at openssh.com,ssh-ed25519-cert-v01 at openssh.com,ssh-dss-cert-v01 at openssh.com,ssh-dss-cert-v00 at 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 at openssh.com,aes256-gcm at openssh.com,chacha20-poly1305 at openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc at lysator.liu.se debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm at openssh.com,aes256-gcm at openssh.com,chacha20-poly1305 at openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc at lysator.liu.se debug2: kex_parse_kexinit: hmac-md5-etm at openssh.com,hmac-sha1-etm at openssh.com,umac-64-etm at openssh.com,umac-128-etm at openssh.com,hmac-sha2-256-etm at openssh.com,hmac-sha2-512-etm at openssh.com,hmac-ripemd160-etm at openssh.com,hmac-sha1-96-etm at openssh.com,hmac-md5-96-etm at openssh.com,hmac-md5,hmac-sha1,umac-64 at openssh.com,umac-128 at openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160 at openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5-etm at openssh.com,hmac-sha1-etm at openssh.com,umac-64-etm at openssh.com,umac-128-etm at openssh.com,hmac-sha2-256-etm at openssh.com,hmac-sha2-512-etm at openssh.com,hmac-ripemd160-etm at openssh.com,hmac-sha1-96-etm at openssh.com,hmac-md5-96-etm at openssh.com,hmac-md5,hmac-sha1,umac-64 at openssh.com,umac-128 at openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160 at openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,zlib at openssh.com,zlib debug2: kex_parse_kexinit: none,zlib at 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: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1 debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-cbc,aes128-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc at lysator.liu.se,cast128-cbc debug2: kex_parse_kexinit: aes128-cbc,aes128-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,rijndael128-cbc,rijndael192-cbc,rijndael256-cbc,rijndael-cbc at lysator.liu.se,cast128-cbc debug2: kex_parse_kexinit: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,none debug2: kex_parse_kexinit: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,none debug2: kex_parse_kexinit: none,none debug2: kex_parse_kexinit: none,none 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: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: RSA f3:0e:1c:c8:14:c9:11:b1:f4:6a:a3:4b:8d:66:0b:f7 debug3: put_host_port: [127.0.0.1]:10037 debug3: put_host_port: [127.0.0.1]:10037 debug3: load_hostkeys: loading entries for host "[127.0.0.1]:10037" from file "unixbuild/known_hosts" debug3: load_hostkeys: found key type RSA in file unixbuild/known_hosts:12 debug3: load_hostkeys: loaded 1 keys debug1: Host '[127.0.0.1]:10037' is known and matches the RSA host key. debug1: Found key in unixbuild/known_hosts:12 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: build/protkey (0x7f0ac907ed90), explicit debug1: Authentications that can continue: password,gssapi-with-mic,publickey debug3: start over, passed a different list password,gssapi-with-mic,publickey debug3: preferred publickey,keyboard-interactive debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: build/protkey debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 535 debug2: input_userauth_pk_ok: fp 94:64:fc:54:e6:91:82:ee:c4:4e:ae:bd:cd:15:36:fa debug3: sign_and_send_pubkey: RSA 94:64:fc:54:e6:91:82:ee:c4:4e:ae:bd:cd:15:36:fa debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). Authenticated to 127.0.0.1 ([127.0.0.1]:10037). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Entering interactive session. debug2: callback start debug2: fd 3 setting TCP_NODELAY debug3: packet_set_tos: set IP_TOS 0x08 debug2: client_session2_setup: id 0 debug1: Sending environment. debug1: Sending command: powershell echo hello debug2: channel 0: request exec confirm 1 debug2: callback done debug2: channel 0: open confirm rwindow 131072 rmax 98304 debug2: channel_input_status_confirm: type 99 id 0 debug2: exec request accepted on channel 0 debug2: channel 0: rcvd adjust 0 hello <-------------------------------------------------- OUTPUT HERE debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug2: channel 0: rcvd close debug2: channel 0: output open -> drain debug2: channel 0: close_read debug2: channel 0: input open -> closed debug3: channel 0: will not send data after close debug2: channel 0: obuf empty debug2: channel 0: close_write debug2: channel 0: output drain -> closed debug2: channel 0: almost dead debug2: channel 0: gc: notify user debug2: channel 0: gc: user detached debug2: channel 0: send close debug2: channel 0: is dead debug2: channel 0: garbage collecting debug1: channel 0: free: client-session, nchannels 1 debug3: channel 0: status: The following connections are open: #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1) Transferred: sent 4096, received 1944 bytes, in 0.9 seconds Bytes per second: sent 4658.3, received 2210.9 debug1: Exit status 0
On 22 Sep 2015, at 12:54, Alex Bligh <alex at alex.org.uk> wrote:> I'm a bit at my wits end with this one. > > I'm seeing a problem where an automated script fails if it doesn't have a tty. Stripping it right back, the issue is that (open)ssh to a Windows build box VM succeeds if openssh has a controlling pty, and fails if it doesn't. > > IE: > > ssh -T host command succeeds > ssh -tt host command succeeds > nohup ssh -T host command fails > nohup ssh -tt host command fails > > I'm running under 'env -i' to clear the environment off. > > I have verified the MS end is not actually running the command (as opposed to merely the output not showing) - for one it's 100 times quicker without nohup. > > I'm running: > OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014I have a suspicion this might be an openssh client. strace shows the connection dies after receiving EBADF. However broken the ssh server is, I don't think openssh should be reading from an FD that returns EBADF. Here's ssh launched with 'nohup'. Node the EBADF near the end (when it decides the connection is dead). 26857 1442926333.820491 write(2, "debug1: Entering interactive session.\r\n", 39) = 39 26857 1442926333.820580 rt_sigaction(SIGHUP, NULL, {SIG_IGN, [], 0}, 8) = 0 26857 1442926333.820658 rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0 26857 1442926333.820734 rt_sigaction(SIGINT, {SIG_IGN, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.820804 rt_sigaction(SIGINT, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fac479f6d40}, 8) = 0 26857 1442926333.820873 rt_sigaction(SIGINT, {0x7fac48e37950, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.820942 rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], 0}, 8) = 0 26857 1442926333.821010 rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.821078 rt_sigaction(SIGQUIT, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fac479f6d40}, 8) = 0 26857 1442926333.821148 rt_sigaction(SIGQUIT, {0x7fac48e37950, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.821216 rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0 26857 1442926333.821285 rt_sigaction(SIGTERM, {SIG_IGN, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.821353 rt_sigaction(SIGTERM, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fac479f6d40}, 8) = 0 26857 1442926333.821421 rt_sigaction(SIGTERM, {0x7fac48e37950, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.821489 rt_sigaction(SIGWINCH, NULL, {SIG_DFL, [], 0}, 8) = 0 26857 1442926333.821557 rt_sigaction(SIGWINCH, {0x7fac48e37bd0, [], SA_RESTORER, 0x7fac479f6d40}, NULL, 8) = 0 26857 1442926333.821642 select(7, [3], [3], NULL, NULL) = 1 (out [3]) 26857 1442926333.821729 write(3, "\rN\0360KugC\333\245\311\30\rNPM\22)\265\223-\313\301U\363dk\241\312\354\274\303\314^(I\36z\360V\205\376\354TJ\364\v\227\217\227\tP\"\31O\233zy\17\372\337\226\3211", 64) = 64 26857 1442926333.821892 select(7, [3], [], NULL, NULL) = 1 (in [3]) 26857 1442926333.822569 read(3, "zU\357\210T\356\241_y\263\v\301\217\351\355/{\206\264\2230\177\270\263r\255n\321\226[\33\25 \23\\\311\260\254\0e\261\327\3227\4\326\230\234", 8192) = 48 26857 1442926333.822683 write(2, "debug2: callback start\r\n", 24) = 24 26857 1442926333.822781 getsockopt(3, SOL_TCP, TCP_NODELAY, [0], [4]) = 0 26857 1442926333.822849 write(2, "debug2: fd 3 setting TCP_NODELAY\r\n", 34) = 34 26857 1442926333.822912 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0 26857 1442926333.822972 getsockname(3, {sa_family=AF_INET, sin_port=htons(33222), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0 26857 1442926333.823039 write(2, "debug3: packet_set_tos: set IP_TOS 0x08\r\n", 41) = 41 26857 1442926333.823101 setsockopt(3, SOL_IP, IP_TOS, [8], 4) = 0 26857 1442926333.823163 write(2, "debug2: client_session2_setup: id 0\r\n", 37) = 37 26857 1442926333.823228 write(2, "debug1: Sending environment.\r\n", 30) = 30 26857 1442926333.823294 write(2, "debug1: Sending command: powershell /c echo hello\r\n", 51) = 51 26857 1442926333.823359 write(2, "debug2: channel 0: request exec confirm 1\r\n", 43) = 43 26857 1442926333.823445 write(2, "debug2: callback done\r\n", 23) = 23 26857 1442926333.823510 write(2, "debug2: channel 0: open confirm rwindow 131072 rmax 98304\r\n", 59) = 59 26857 1442926333.823582 select(7, [3 4], [3], NULL, NULL) = 2 (in [4], out [3]) 26857 1442926333.823652 read(4, 0x7ffee032e970, 16384) = -1 EBADF (Bad file descriptor) 26857 1442926333.823725 write(2, "debug2: channel 0: read<=0 rfd 4 len -1\r\n", 41) = 41 26857 1442926333.823798 write(2, "debug2: channel 0: read failed\r\n", 32) = 32 26857 1442926333.823884 write(2, "debug2: channel 0: close_read\r\n", 31) = 31 26857 1442926333.823951 close(4) = 0 .... Here's ssh launched without 'nohup': 27010 1442926394.519659 write(2, "debug1: Entering interactive session.\r\n", 39) = 39 27010 1442926394.519886 rt_sigaction(SIGHUP, NULL, {SIG_DFL, [], 0}, 8) = 0 27010 1442926394.519961 rt_sigaction(SIGHUP, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520033 rt_sigaction(SIGHUP, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, 8) = 0 27010 1442926394.520114 rt_sigaction(SIGHUP, {0x7fcfdc60d950, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520185 rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0 27010 1442926394.520257 rt_sigaction(SIGINT, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520327 rt_sigaction(SIGINT, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, 8) = 0 27010 1442926394.520398 rt_sigaction(SIGINT, {0x7fcfdc60d950, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520469 rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], 0}, 8) = 0 27010 1442926394.520539 rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520622 rt_sigaction(SIGQUIT, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, 8) = 0 27010 1442926394.520703 rt_sigaction(SIGQUIT, {0x7fcfdc60d950, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520773 rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0 27010 1442926394.520844 rt_sigaction(SIGTERM, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.520914 rt_sigaction(SIGTERM, NULL, {SIG_IGN, [], SA_RESTORER, 0x7fcfdb1ccd40}, 8) = 0 27010 1442926394.520985 rt_sigaction(SIGTERM, {0x7fcfdc60d950, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.521056 rt_sigaction(SIGWINCH, NULL, {SIG_DFL, [], 0}, 8) = 0 27010 1442926394.521127 rt_sigaction(SIGWINCH, {0x7fcfdc60dbd0, [], SA_RESTORER, 0x7fcfdb1ccd40}, NULL, 8) = 0 27010 1442926394.521208 select(7, [3], [3], NULL, NULL) = 1 (out [3]) 27010 1442926394.521295 write(3, "BG]\251\32b\217z\315\30d\17)\345\266\6\317\37\1\347j\224\10\350\321\347u{^\316\313\216\225\345\27\344\373\373q#mY\25\t\2553R]\371\372!\3756Uo92/j\325\4Z\200\346", 64) = 64 27010 1442926394.521611 select(7, [3], [], NULL, NULL) = 1 (in [3]) 27010 1442926394.522086 read(3, "H\21\331!\370f\2373\34\306X1\376'\335X\"\326\277\25\321\332,\312\237N\341y\362\3721\236N\303\0169\313\2\30\2\216u\333TZ.\357\333", 8192) = 48 27010 1442926394.522178 write(2, "debug2: callback start\r\n", 24) = 24 27010 1442926394.522282 getsockopt(3, SOL_TCP, TCP_NODELAY, [0], [4]) = 0 27010 1442926394.522366 write(2, "debug2: fd 3 setting TCP_NODELAY\r\n", 34) = 34 27010 1442926394.522458 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0 27010 1442926394.522534 getsockname(3, {sa_family=AF_INET, sin_port=htons(33230), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0 27010 1442926394.522628 write(2, "debug3: packet_set_tos: set IP_TOS 0x08\r\n", 41) = 41 27010 1442926394.522719 setsockopt(3, SOL_IP, IP_TOS, [8], 4) = 0 27010 1442926394.522798 write(2, "debug2: client_session2_setup: id 0\r\n", 37) = 37 27010 1442926394.522892 write(2, "debug1: Sending environment.\r\n", 30) = 30 27010 1442926394.522985 write(2, "debug1: Sending command: powershell /c echo hello\r\n", 51) = 51 27010 1442926394.523085 write(2, "debug2: channel 0: request exec confirm 1\r\n", 43) = 43 27010 1442926394.523264 write(2, "debug2: callback done\r\n", 23) = 23 27010 1442926394.523391 write(2, "debug2: channel 0: open confirm rwindow 131072 rmax 98304\r\n", 59) = 59 27010 1442926394.523523 select(7, [3 4], [3], NULL, NULL) = 1 (out [3]) 27010 1442926394.523616 write(3, "V0\300\\kSoD\353E\"+\344\7\251|\367s\232\22728\22\273\321\345\2H\321u\303Y\31A\237\201\271\326\21\367\360\350\242\353\266\210m\20r\2156\3447\316\5\24.\356\342p\17~D\371\2\245\245\205&T\20\3533F4_\202\273\36\347", 80) = 80 27010 1442926394.523733 select(7, [3 4], [], NULL, NULL) = 1 (in [3]) 27010 1442926394.524474 read(3, "BV\351\356\351\353\340#{@\\6\341>\352)\342\241\307\270j\305\10J\322i`,\214\346a\275", 8192) = 32 27010 1442926394.524570 write(2, "debug2: channel_input_status_confirm: type 99 id 0\r\n", 52) = 52 27010 1442926394.524689 write(2, "debug2: exec request accepted on channel 0\r\n", 44) = 44 27010 1442926394.524785 select(7, [3 4], [], NULL, NULL) = 1 (in [3]) 27010 1442926394.526720 read(3, "\262>\177ta\276\20\375\314\347\2441\240\254<|[\344\272\320\345X,\311\342\201q\241CV\"\314\305\2\314!|pq\235\341\22Y\"N\24Z\261", 8192) = 48 27010 1442926394.526816 write(2, "debug2: channel 0: rcvd adjust 0\r\n", 34) = 34 27010 1442926394.526906 select(7, [3 4], [], NULL, NULL) = 1 (in [3]) 27010 1442926395.409546 read(3, "(\303\273\333H\217o\306\353\372\344(\340{\177\366<\323\237\300\223\251N\316E\0313PS$a\5\2334\372\226\324\33-QO\237\206C\3342(8", 8192) = 48 27010 1442926395.409610 select(7, [3 4], [5], NULL, NULL) = 1 (out [5]) 27010 1442926395.409698 write(5, "hello\r\n", 7) = 7 27010 1442926395.409891 select(7, [3 4], [], NULL, NULL) = 1 (in [3]) 27010 1442926395.440588 read(3, "\251d\352\315\351\26\276\316\246\321k\270\276\243\376=\343\273\372\205a\37R\34\271\304\203<\326\27\354%\35\322\366f\363\246\307\373\212-\32\327\214\277-\255\2612\304\254\256\337\2\216\35\230D2\35LN\365", 8192) = 64 27010 1442926395.440649 write(2, "debug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r\n", 71) = 71 27010 1442926395.440805 select(7, [3 4], [], NULL, NULL) = 1 (in [3]) 27010 1442926395.440935 read(3, "\324<,J\321\250\325H\376\322\230,\312\331\204\312&\266\230\221\240\3200\304\252\352lE\246\311\336]", 8192) = 32 27010 1442926395.441016 write(2, "debug2: channel 0: rcvd close\r\n", 31) = 31 27010 1442926395.441082 write(2, "debug2: channel 0: output open -> drain\r\n", 41) = 41 27010 1442926395.441144 write(2, "debug2: channel 0: close_read\r\n", 31) = 31 27010 1442926395.441234 close(4) = 0 27010 1442926395.441286 write(2, "debug2: channel 0: input open -> closed\r\n", 41) = 41 27010 1442926395.441382 write(2, "debug3: channel 0: will not send data after close\r\n", 51) = 51 27010 1442926395.441479 write(2, "debug2: channel 0: obuf empty\r\n", 31) = 31 27010 1442926395.441571 write(2, "debug2: channel 0: close_write\r\n", 32) = 32 27010 1442926395.441647 close(5) = 0 27010 1442926395.441708 write(2, "debug2: channel 0: output drain -> closed\r\n", 43) = 43 27010 1442926395.441796 write(2, "debug2: channel 0: almost dead\r\n", 32) = 32 .... The relevant lines seem to be: 26857 1442926333.818989 dup(0) = 4 26857 1442926333.819057 dup(1) = 5 26857 1442926333.819125 dup(2) = 6 ... 26857 1442926333.823582 select(7, [3 4], [3], NULL, NULL) = 2 (in [4], out [3]) 26857 1442926333.823652 read(4, 0x7ffee032e970, 16384) = -1 EBADF (Bad file descriptor) ... 27010 1442926395.441234 close(4) = 0 i.e. FD 4 is open (or the close would have errored), but returns EBADF. I believe EBADF is only returned if the FD is closed, or not open for reading. I think this happens because FD 0 gets set up like this by nohup: 28728 1442927535.524873 open("/dev/null", O_WRONLY) = 3 28728 1442927535.524947 dup2(3, 0) = 0 28728 1442927535.525008 close(3) = 0 Per line 125 of https://fossies.org/dox/coreutils-8.24/nohup_8c_source.html this is deliberate. 115 ignoring_input = isatty (STDIN_FILENO); 116 redirecting_stdout = isatty (STDOUT_FILENO); 117 stdout_is_closed = (!redirecting_stdout && errno == EBADF); 118 redirecting_stderr = isatty (STDERR_FILENO); 119 120 /* If standard input is a tty, replace it with /dev/null if possible. 121 Note that it is deliberately opened for *writing*, 122 to ensure any read evokes an error. */ 123 if (ignoring_input) 124 { 125 if (fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0) < 0) 126 error (exit_internal_failure, errno, 127 _("failed to render standard input unusable")); 128 if (!redirecting_stdout && !redirecting_stderr) 129 error (0, 0, _("ignoring input")); 130 } 131 132 ('cron' and 'at' appear to do similarly) And I have no idea why ssh should be reading from stdin when executing a command with -T. -- Alex Bligh