Skip to main content
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
Source Link
Mtl Dev
  • 533
  • 1
  • 8
  • 18

How to log myself out of ssh, from a bash script?

Connected to a remote server via SSH.

On occasion, I run a specific bash script. When certain conditions are met (it's work completed successfully), I wish to be automatically logged out of the SSH tunnel. In the normal login shell, I simply type logout to logout.

I am unable to do this from a bash script. If I put logout in a bash script, the error is:
logout: not login shell: use `exit'

Query: How do you automatically log yourself out of an SSH connection from a bash script?