SSH/zh-cn

SSH (Secure SHell) is an encrypted terminal program that replaces the classic telnet tool on Unix-like operating systems.

In addition to remote terminal access provided by the main ssh binary, the SSH suite of programs has grown to include other tools such as scp (in very common use) and sftp (less common).

最初，SSH 并不是免费的. 然而，现今大部分流行的和事实标准的 SSH 软件是 OpenBSD 的 OpenSSH，它在 Gentoo 中已预安装.

服务端
OpenSSH 服务器可以通过 /etc/init.d/ssh start，/etc/init.d/ssh stop 和 /etc/init.d/ssh restart 来控制，就像其它 OpenRC 管理的服务一样.

注意，当执行 /etc/init.d/ssh restart 时，连接至服务器的活动连接并不受影响，但是使用 /etc/init.d/ssh stop，/etc/init.d/ssh start 则会导致断开连接.

Server configuration
The SSH server is usually configured in the file, though it is also possible to perform further configuration in OpenRC's, including changing the location of the former. For detailed information on how to configure the server see the sshd_config man page.

您应当也看一看这份偏重于安全的指南.

客户端配置
ssh 客户端与相关的程序（scp，sftp 等等）在 文件中配置. 请查看 ssh_config 手册页查询更多关于如何配置这些程序的信息.

无密码验证
对于管理 git 服务器非常便利.

Client
on your client run

then hit enter like 5 times to generate your key move the client ~/.ssh/id_rsa.pub to the server user your logging in as ~/.ssh/authorized_keys

服务器
添加一个用户

将客户端的 id_rsa.pub 文件放至新用户的 ~/.ssh/authorized_keys

Single Machine Testing
enter 5 times

Troubleshooting
There are 3 different levels of debug modes. -v Causes ssh to print debugging messages about its progress. This is helpful in debugging connection, authentication, and configuration problems. Multiple -v options increase the verbosity. The maximum is 3.

debug1 mode:

debug2 mode:

debug3 mode:

Death of Long-lived Connections
Many internet access devices perform network address translation (NAT), a process that enables devices on a private network such as that typically found in a home or business place to access foreign networks, such as the internet, despite only having a single IP address on that network. Unfortunately, not all NAT devices are created equal, and some of them incorrectly close long-lived, occasional-use TCP connections such as those used by SSH. This is generally observable as a sudden inability to interact with the remote server, though the ssh client program has not exited.

In order to resolve the issue, OpenSSH clients and servers can be configured to send a 'keep alive', or invisible message aimed at maintaining and confirming the live status of the link.
 * To enable keep alive for all clients connecting to your local server, set ClientAliveInterval 30 (or some other value, in seconds) within the file.
 * To enable keep alive for all servers connected to by your local client, set ServerAliveInterval 30 (or some other value, in seconds) within the file.