如何为多个Linux服务器创建ssh?

如何为多个Linux服务器创建ssh?

更新*

我有两台 Linux 服务器 CentOS 7 和 Debian 6,在 virtual Box 内运行易受攻击的 Web 应用程序,我的主机操作系统是 Kali Linux,并通过仅主机适配器设置连接到两个虚拟机。我可以成功 SSH 到 CentOS,但是当我 SSH 到 Debian 时,它说主机验证失败,我的问题是如何 ssh 到 debian 而不会出现错误或连接到多个虚拟机?

“很抱歉没有提前提供足够的信息”,我有详细信息

ssh_配置

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   -o CheckHostIP no 192.168.56.101
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking no
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com

#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no
    NoHostAuthenticationForLocalhost yes

sshd_配置

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server`enter code here`

答案1

你有两个选择:

  • -o "CheckHostIP no"向 ssh 命令行添加选项;
  • 将以下代码片段添加到您的~/.ssh/config文件中:

您的虚拟机的主机 IP 地址

检查主机IP号

更新:

我从您的更新中得到的信息是否正确,您目录中的文件~/.ssh名为ssh_config?如果这是真的,那么你就犯了一个错误:它应该被命名为config(不带ssh_

在您发布的配置中,您显然添加了一行:

#   -o CheckHostIP no 192.168.56.101

它看起来应该完全不同:

Host 192.168.56.101
CheckHostIP no

最好将这两行放在文件的最后config,以便 VM 主机的条目派生出您设置的所有其他设置。

相关内容