Mac terminal SSH Connection server is disconnected when idle

Source: Internet
Author: User
Tags ssh server dns spoofing

Ssh_config Detailed (MAC OSX)

Method 1:MAC Client Configuration

Configuring the "/etc/ssh/ssh_config" file

The "/etc/ssh/ssh_config" file is a OpenSSH system-wide configuration file that allows you to change the way the client program runs by setting different options. Each line of this file contains a "keyword-value" match, where "keyword" is ignored and case-sensitive. The most important keywords are listed below, with the Man command to view the help page (SSH (1)) to get a detailed list.


Edit the "ssh_config" file

sudo-s ( enable Superuser Sudo-s gain system privileges)

Vi/etc/ssh/ssh_config

In

Host * Add below

Serveraliveinterval 60

(Press I to edit, save Yes: ESC to command mode, Knock Colon:, then wq! (3 characters), the Save exits, [w is saved, Q is exited, can be used alone,! is mandatory])

(the option settings are described in line by row below:
Host *
The option "Host" is valid only for computers that can match the following string. "*" means all computers.

Forwardagent No
"Forwardagent" Sets whether the connection is forwarded to the remote computer through the authentication agent (if present).

ForwardX11 No
"ForwardX11" sets whether the X11 connection is automatically redirected to a secure channel and display set.

Rhostsauthentication No
The "rhostsauthentication" setting uses rhosts-based security authentication.

Rhostsrsaauthentication No
The "rhostsrsaauthentication" setting uses rhosts-based security authentication with the RSA algorithm.

Rsaauthentication Yes
The "rsaauthentication" setting uses the RSA algorithm for security verification.

Passwordauthentication Yes
The "passwordauthentication" Setting uses password authentication.

Fallbacktorsh No
The "Fallbacktorsh" setting if an error occurs with an SSH connection automatically uses RSH.

Usersh No
"Usersh" sets whether to use "Rlogin/rsh" on this computer.

Batchmode No
"Batchmode" If set to "yes", the hint of passphrase/password (interactive input password) will be disabled. This option is useful for script files and batch processing tasks when passwords cannot be entered interactively.

Checkhostip Yes
"Checkhostip" sets whether SSH views the IP address of the host connected to the server to prevent DNS spoofing. Suggestions??? Set to "Yes".

Stricthostkeychecking No
"Stricthostkeychecking" If set to "Yes", SSH will not automatically add the computer's key "$HOME/.ssh/known_hosts" file, and once the computer's key has changed, refused to connect.

Identityfile ~/.ssh/identity
"Identityfile" sets the file from which to read the user's RSA Security authentication identity.

Port 22
"Port" sets the port to connect to the remote host.

Cipher Blowfish
"Cipher" sets the password for encryption.

Escapechar ~
"Escapechar" sets the escape character.


method Two: service-side configuration
Configuring the "/etc/ssh/sshd_config" file

Linux System Server

When using SSH to connect a remote server to a Linux system, you can use one of the parameter serveraliveinterval of-O to set the time to prevent timeouts.

For example: Ssh-o serveraliveinterval=60 [email protected]

Server Configuration Modifications

Modify the SSH configuration file/etc/ssh/sshd_config, add or modify Clientaliveinterval to "Clientaliveinterval 60". This parameter means that every 1 minutes, the server sends a message to the client to keep the connection. Remember to restart the SSH service after saving.

After the modification, the above several methods can let SSH stay connected, always in the alive state, not because there is no operation to be forced by the server disconnected.


"/etc/ssh/sshd_config" is a openssh configuration file that allows setting options to change the operation of this daemon. Each line of this file contains a "keyword-value" match, where "keyword" is ignored and case-sensitive. The following list is the most important keywords, the man command to view the help page (sshd (8)) to get a detailed listing.

Edit the "sshd_config" file (vi/etc/ssh/sshd_config) to add or change the following parameters:

# This is the SSH server systemwide configuration file.
Port 22
ListenAddress 192.168.1.1
Hostkey/etc/ssh/ssh_host_key
Serverkeybits 1024
Logingracetime 600
Keyregenerationinterval 3600
Permitrootlogin No
Ignorerhosts Yes
Ignoreuserknownhosts Yes
Strictmodes Yes
X11forwarding No
PRINTMOTD Yes
Syslogfacility AUTH
LogLevel INFO
Rhostsauthentication No
Rhostsrsaauthentication No
Rsaauthentication Yes
Passwordauthentication Yes
Permitemptypasswords No
Allowusers Admin

The following line shows the option settings above:

Port 22
"Port" sets the port number of the sshd listener.

Mac terminal SSH Connection server is disconnected when idle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.