Linux配置ssh

发布时间 2023-11-23 19:14:17作者: 败人两字非傲即惰
kali网络经常抽风,遇到这种不符合常理的情况要重启

安装
debian系列
    sudo apt install openssh-client
    sudo apt install openssh-server
redhat系列
    sudo yum install openssh-server
启动
    sudo service ssh start
service ssh start
service start ssh不行
systemctl restart ssh
systemctl ssh restart不行
是ssh不是sshd
还可以配置ssh
vim /etc/ssh/ssh_config
PasswordAuthentication yes

vim /etc/ssh/sshd_config
PermitRootLogin yes
systemctl restart ssh
systemctl enable ssh

systemctl restart networking


问题:Unable to negotiate with 192.168.8.40 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
解法:https://ttys3.dev/post/openssh-8-8-p1-no-matching-host-key-type-found-their-offer-ssh-rsa/
编辑用户 ssh 配置 ~/.ssh/config, 对于无法成功连接的host, 增加配置项:

  HostKeyAlgorithms         +ssh-rsa
  PubkeyAcceptedKeyTypes    +ssh-rsa
完整的配置可能看起来像这样:

Host myhost
  Hostname     1.1.1.1
  User user001
  IdentityFile     ~/.ssh/id_rsa
  # fixup for openssh 8.8
  HostKeyAlgorithms +ssh-rsa
  PubkeyAcceptedKeyTypes +ssh-rsa
或者,像我一样的懒人:

Host *
     ServerAliveInterval 10
      HostKeyAlgorithms +ssh-rsa
      PubkeyAcceptedKeyTypes +ssh-rsa