OpenSSH SSH客户端配置

时间:2020-03-21 11:46:29  来源:igfitidea点击:

Debian Wheezy上OpenSSH客户端的配置说明。

OpenSSH SSH客户端

安装OpenSSH SSH客户端:

# apt-get install openssh-client

SSH客户端按照以下顺序从以下来源获取配置数据:

  • 命令行选项
  • 用户的配置文件('~/.ssh/config'),
  • 系统范围的配置文件('/etc/ssh/ssh_config')。

对于每个参数,使用第一个获得的值。

主机特定的声明

配置示例:

$cat "$HOME"/.ssh/config
Host gateway
	HostName 10.0.0.1
	Port 22
	User admin
	PreferredAuthentications password,publickey
Host webserver
	HostName www.example.com
	Port 12
	User root
	IdentityFile /home/"$USER"/.ssh/web.pem
Host mysql-tunnel
	HostName db.example.com
	Port 12
	User ubuntu
	IdentityFile /home/"$USER"/.ssh/db.pem
	LocalForward 53306 127.0.0.1:3306

通用默认值

配置示例:

$grep -ve "^#" -ve "^$" /etc/ssh/ssh_config
Host *

AddressFamily inet

Protocol 2

PasswordAuthentication yes

HostbasedAuthentication no

GSSAPIAuthentication no

GSSAPIDelegateCredentials no

CheckHostIP yes

SendEnv LANG LC_*

HashKnownHosts yes