公认端口22 这玩意儿居然还能传文件??Secure Copy Protocal

安装

Linux

sudo apt install openssh-server

ipv6: ssh username@[ipv6_address]

Windows

windows功能打开open ssh #todo

进阶用法

密钥对登录

  • 在客户端生成密钥对(保障私钥不过公网):ssh-keygen -t ed25519 -C "注释"
    • 直接回车。想加二层密码可以加
    • 私钥:~/.ssh/id_ed25519
    • 公钥:~/.ssh/id_ed25519.pub
  • 注册公钥:ssh-copy-id -i ~/.ssh/id_ed25519.pub <user>@<ip> todo
  • 调整授权列表权限:chmod 600 ~/.ssh/authorized_keys
  • 调整目录权限:chmod 700 ~/.ssh
  • 将私钥放到客户端上开始使用
  • 关闭密码登录的方式(记得先测试私钥连接正不正常)
    • 更改/etc/ssh/sshd_config.d/,将PasswordAuthentication改为no
    • 如果找不到上述文件夹(旧版ssh),将/etc/ssh/sshd_config中的PasswordAuthentication改为no

常见问题

  • 始终保持链接不断开
    • putty: 打开saved sessions中需要配置的会话,Connectionseconds between keepalive设置为非0数
    • macOS:编辑~/.ssh/config,末尾添加以下内容
Host syner.top 
  Port 13966
  ServerAliveInterval 60
  ServerAliveCountMax 3