2024年6月9日发(作者:)

linux下的ssh配置

配置“/etc/ssh/ssh_config”文件

“/etc/ssh/ssh_config” 文件是OpenSSH系统范围的配置文件,

允许你通过设置不同的选项来改变客户端程序的运行方式。这个文件

的每一行

包含“关键词-值”的匹配,其中“关键词”是忽略大小写的。

下面列出来的是最重要的关键词,用man命令查看帮助页(ssh (1))

可以得到

详细的列表。

编辑“ssh_config”文件(vi /etc/ssh/ssh_config),添加或改

变下面的参数:

# Site-wide defaults for various options

Host *

ForwardAgent no

ForwardX11 no

RhostsAuthentication no

RhostsRSAAuthentication no

RSAAuthentication yes

PasswordAuthentication yes

FallBackToRsh no

UseRsh no

BatchMode no

CheckHostIP yes

StrictHostKeyChecking no

IdentityFile ~/.ssh/identity

Port 22

Cipher blowfish

EscapeChar ~

下面逐行说明上面的选项设置:

Host *

选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所

有的计算机。

ForwardAgent no

“ForwardAgent”设置连接是否经过验证代理(如果存在)转

发给远程计算机。

ForwardX11 no

“ForwardX11”设置X11连接是否被自动重定向到安全的通道

和显示集(DISPLAY set)。

RhostsAuthentication no

“RhostsAuthentication”设置是否使用基于rhosts的安全验证。

RhostsRSAAuthentication no

“RhostsRSAAuthentication”设置是否使用用RSA算法的基于

rhosts的安全验证。

RSAAuthentication yes

“RSAAuthentication”设置是否使用RSA算法进行安全验证。

PasswordAuthentication yes

“PasswordAuthentication”设置是否使用口令验证。

FallBackToRsh no

“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用

rsh。

UseRsh no

“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。

BatchMode no

“BatchMode”如果设为“yes”,passphrase/password(交

互式输入口令)的提示将被禁止。当不能交互式输入口令的时候,这

个选项对脚本

文件和批处理任务十分有用。

CheckHostIP yes