I am trying to keep connections alive to my university server. It keeps disconnecting after 2-3 minutes of inactivity and it gets very frustrating to keep relogging in. I tried many things online but I am unable to edit any of the files.

I have tried following instructions here: https://www.a2hosting.com/kb/getting-started-guide/accessing-your-account/keeping-ssh-connections-alive

Perhaps the problem is that I dont have a ~/.ssh/config file - changes I try to make to the below given files, I keep getting this:

  1. -- INSERT -- W10: Warning: Changing a readonly file
  2. E45: 'readonly' option is set (add ! to override)
  3. "sshd_config" E212: Can't open file for writing

When I try to create it (copy and paste the command you use here), it says this:

mkdir: .ssh: Permission denied

I am happy to answer any further questions you may have :)

This is what my /etc/ssh looks like:

enter image description here

This is what ssh_config looks like: enter image description here

and this is what my sshd_config looks like: enter image description here

Is there a better guide to creating my ssh config so I can have my client ssh keep alive the connection to the server?

  • Welcome to Ask Different. I’ll edit out the “i tried everything” that tends to make people think you can’t be helped. If you want to edit in specific research you followed and explain how specifically it failed - then we can often help quickly.
    – bmike
    Jun 6, 2020 at 18:56
  • mkdir -p ~/.ssh should make that directory - can you edit out that error or edit in how you are creating your config file? Also - I am a little perplexed why your system didn’t make that directory when you had your first successful ssh out to make known_hosts file. - perhaps you have a non-standard user folder or have some other breakage
    – bmike
    Jun 6, 2020 at 18:59
  • Please share information as textr and not images so that we can read it.
    – mmmmmm
    Jun 24, 2021 at 16:58

1 Answer 1


Catalina is same as all the older OS X and macOS for this. For you, it seems the hidden ssh folder is what’s stopping your attempt to configure the file. My commands make the directory and then clobber any file you may have so don’t use the cat > and expect to keep old file contents. You can then edit the file once it’s set.

mkdir -p ~/.ssh
cat > ~/.ssh/config << EOF
Host keepsdroppingme.com
ServerAliveInterval 120

Of course you need to put the host you care about having the 120 second keep alive traffic being synthetically generated whether you’re typing or not. On the server side, they can still enforce a timeout, but this often works wonders.

  • 1
    Do these changes immediately go into effect or do you need to restart or start a new ssh connection or restart terminal? Jun 24, 2021 at 13:50
  • @LindsayHayes They apply for all future connections, so if you are already connected to keepsdroppingme.com you need to reconnect.
    – nohillside
    Jun 24, 2021 at 15:22

You must log in to answer this question.

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