SSH远程连接命令:

  用法格式:ssh IPADDR 不指定用户则以当前主机登录系统的用户身份去登录远程主机

    ssh USERNAME@IPADDR  通过ssh协议以某用户身份远程登录到某主机

Usage: ssh root@192.168.1.100  以root身份通过ssh协议远程登录到192.168.1.100主机

    ssh -l USERNAME IPADDR 相当于ssh USERNAME@IPADDR登录模式一样

    ssh USERNAME@IPADDR 'COMMOND' 以USERNAME用户在远程主机上执行COMMOND命令。


 openssl服务器端的服务名为:sshd  配置文件为:/etc/ssh/sshd_config

    sshd_config配置文件的详解:

   

# The strategy used for options in the default sshd_config shipped with

# OpenSSH is to specify options with their default value where

# possible, but leave them commented.  Uncommented options change a

# default value.


#Port 22      端口号

#Protocol 2,1

Protocol 2    协议版本2

#AddressFamily any    支持IP地址是IPV4或IPV6;any表示两种IP地址都可以

#ListenAddress 0.0.0.0  表示给那些主机提供sshd服务,0.0.0.0表示所有主机

#ListenAddress ::


# HostKey for protocol version 1 

#HostKey /etc/ssh/ssh_host_key   版本1使用的密钥文件

# HostKeys for protocol version 2

#HostKey /etc/ssh/ssh_host_rsa_key  版本2使用的rsa认证的密钥文件

#HostKey /etc/ssh/ssh_host_dsa_key  版本2使用的dsa认证的密钥文件

 

# Lifetime and size of ephemeral version 1 server key

#KeyRegenerationInterval 1h     密钥重新生成的间隔时间(即每个一小时密钥自动更换,防止暴                        力破解)

#ServerKeyBits 768   密钥长度

 

# Logging

# obsoletes QuietMode and FascistLogging

#SyslogFacility AUTH

SyslogFacility AUTHPRIV   默认使用哪个记录日志。

#LogLevel INFO       日志记录级别(默认为info级别)如需记录别的级别,去掉#修改级别即可

 

# Authentication:

 

#LoginGraceTime 2m   登录的宽限期(即输入用户名需在2分钟内输入密码,否则需重新输入用户名)

#PermitRootLogin yes  是否允许管理员直接通过ssh服务登录(默认为yes允许,如果no表示不允许)

#StrictModes yes   是否使用严格限定模式(默认即可)

#MaxAuthTries 6    默认用户输入密码的限定次数为6,超过该次数,账号直接锁定

 

#RSAAuthentication yes   是否支持rsa认证

#PubkeyAuthentication yes  是否支持密钥认证 

#AuthorizedKeysFile     .ssh/authorized_keys  密钥认证的公钥放置在该用户的家目录的.ssh中

 

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts

#RhostsRSAAuthentication no  是否启用主机认证(即信任某主机不需要登录直接连接)

# similar for protocol version 2

#HostbasedAuthentication no

# Change to yes if you don't trust ~/.ssh/known_hosts for

# RhostsRSAAuthentication and HostbasedAuthentication

#IgnoreUserKnownHosts no

# Don't read the user's ~/.rhosts and ~/.shosts files

#IgnoreRhosts yes


To disable tunneled clear text passwords, change to no here!

#PasswordAuthentication yes  

#PermitEmptyPasswords no 

PasswordAuthentication yes  是否启用基于口令认证

 

# Change to no to disable s/key passwords

#ChallengeResponseAuthentication yes

ChallengeResponseAuthentication no  是否启用挑战式握手认证协议


# Kerberos options

#KerberosAuthentication no

#KerberosOrLocalPasswd yes

#KerberosTicketCleanup yes

#KerberosGetAFSToken no    是否允许kerberos认证协议

 

# GSSAPI options

#GSSAPIAuthentication no

GSSAPIAuthentication yes

#GSSAPICleanupCredentials yes

GSSAPICleanupCredentials yes    是否允许GSS认证机制


# session checks to run without PAM authentication, then enable this but set 

# ChallengeResponseAuthentication=no

#UsePAM no

UsePAM yes  是否使用可插入式PAM认证模块

 

# Accept locale-related environment variables

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES

AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT

AcceptEnv LC_IDENTIFICATION LC_ALL


#AllowTcpForwarding yes

#GatewayPorts no

#X11Forwarding no

X11Forwarding yes    是否转发X11请求

#X11DisplayOffset 10

#X11UseLocalhost yes

#PrintMotd yes

#PrintLastLog yes

#TCPKeepAlive yes

#UseLogin no

#UsePrivilegeSeparation yes

#PermitUserEnvironment no

#Compression delayed

#ClientAliveInterval 0


# no default banner path

#Banner /some/path

 

# override default of no subsystems

Subsystem       sftp    /usr/libexec/openssh/sftp-server  登录的子系统