1

ssh connection closed immediately after I enter password

ssh -v [email protected]
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to 104.238.125.233 [104.238.125.233] port 22.
debug1: Connection established.
debug1: identity file /Users/nicole/.ssh/id_rsa type -1
debug1: identity file /Users/nicole/.ssh/id_rsa-cert type -1
debug1: identity file /Users/nicole/.ssh/id_dsa type -1
debug1: identity file /Users/nicole/.ssh/id_dsa-cert type -1
debug1: identity file /Users/nicole/.ssh/id_ecdsa type -1
debug1: identity file /Users/nicole/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/nicole/.ssh/id_ed25519 type -1
debug1: identity file /Users/nicole/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/nicole/.ssh/id_xmss type -1
debug1: identity file /Users/nicole/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug1: Authenticating to 104.238.125.233:22 as 'hoogw'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:z9djZdxvUnzM6SLpcFo6INz6ixj3YFIF+dM/h3+JHh4
debug1: Host '104.238.125.233' is known and matches the RSA host key.
debug1: Found key in /Users/nicole/.ssh/known_hosts:1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /Users/nicole/.ssh/id_rsa 
debug1: Will attempt key: /Users/nicole/.ssh/id_dsa 
debug1: Will attempt key: /Users/nicole/.ssh/id_ecdsa 
debug1: Will attempt key: /Users/nicole/.ssh/id_ed25519 
debug1: Will attempt key: /Users/nicole/.ssh/id_xmss 
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/nicole/.ssh/id_rsa
debug1: Trying private key: /Users/nicole/.ssh/id_dsa
debug1: Trying private key: /Users/nicole/.ssh/id_ecdsa
debug1: Trying private key: /Users/nicole/.ssh/id_ed25519
debug1: Trying private key: /Users/nicole/.ssh/id_xmss
debug1: Next authentication method: password
[email protected]'s password: 
debug1: Authentication succeeded (password).
Authenticated to 104.238.125.233 ([104.238.125.233]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Fri Apr 24 14:10:52 2020 from 097-090-197-218.res.spectrum.com
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to 104.238.125.233 closed.
Transferred: sent 2600, received 2656 bytes, in 0.1 seconds
Bytes per second: sent 19405.6, received 19823.6
debug1: Exit status 0
nicole@nicoles-iMac ~ % 
8
  • Does ssh [email protected] sh -i give you a shell prompt (it'll be short, such as $). If that works, you can rummage through your dot files to see if there are any errors in them that might cause a login shell to exit. Apr 24, 2020 at 22:23
  • What shell is this "hoogw" account on the remote system set up to use?
    – Kenster
    Apr 25, 2020 at 1:44
  • hoogw is my user name
    – hoogw
    Apr 27, 2020 at 14:20
  • ssh [email protected] sh -i **** I get following ***** sh: cannot set terminal process group (-1): Invalid argument sh: no job control in this shell sh-4.1$
    – hoogw
    Apr 27, 2020 at 14:22
  • @Mark Plotnick, it works, but how to do further "rummage through your dot files to see if there are any errors"?
    – hoogw
    Apr 27, 2020 at 17:47

1 Answer 1

0

I think there is an exit 0 in your .bash_profile. It seems to be the cause of your troubles.

The .bash_profile executes first when you log on to a remote terminal.

Try running this and let us know if the issue persists -

# ssh [email protected] sed -i '/exit\ 0/d' .bashrc .bash_profile

8
  • I never change or create any .bash_profile file, nobody else should touch this server, I am the owner. I need to first locate where is this file? I might not have this file. I do not want to run a command, which I do not know what this command is doing. It could damage my server.
    – hoogw
    Apr 27, 2020 at 14:56
  • .bash_profile is the default profile used by the Bourne Again Shell aka bash when used for login, .bashrc is the default profile when you use bash as an interactive shell. You can verify these files using ls -a. The command is perfectly safe for use on your server.
    – rubaiat
    Apr 27, 2020 at 15:29
  • Use ssh [email protected] ls -a to check them. However, I suggest you simply run the command in my answer and see if the issue persist. It simply checks for any exit 0 in your profile files and delete them so that you're not disconnected from your ssh session. You can add them again if required.
    – rubaiat
    Apr 27, 2020 at 15:36
  • I test your command, it error ----------> sed: can't read .profile: No such file or directory sed: can't read .login: No such file or directory
    – hoogw
    Apr 27, 2020 at 17:45
  • I do not even have a bash_profile, I never create such file before.
    – hoogw
    Apr 27, 2020 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .