DAILY DOCDAILY DOC
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
  • linux
  • bash alias
  • chmod
  • linux useful command
  • date
  • extract translation from git diff
  • fail2ban
  • globbing
  • localhost
  • mail
  • memo 内存测试
  • nohup(no hang up)
  • setup env
  • ssh

    • ssh 教程
    • github clone
    • ssh.localhost.run 端口转发
    • ssh 安全
  • systemd service
  • 分析ubuntu系统登录日志文件
  • vpn

    • vpn 教程
    • Algo
    • clashX
    • firezone
    • lantern
    • pac 代理配置
    • Setup vpn
    • shadowsocks
    • VPN
    • VPN 速度优化
    • wireguard cron
    • 修改wireguard端口
  • webhook

ssh 教程

ssh 通过密钥登录

编辑 ~/.ssh/config文件添加配置

Host test01
  HostName xx.xx.xx.xx
  ForwardAgent yes
  User root

ssh-copy-id上传密钥到服务器

# ssh-copy-id Host
ssh-copy-id test01
ssh-copy-id -i ~/.ssh/xxx test01

登录上之后编辑服务器ssh 配置文件,禁用密码登录。编辑/etc/ssh/sshd_config

PasswordAuthentication no
PermitEmptyPasswords no
PermitRootLogin yes
PubKeyAuthentication yes
RSAAuthentication yes

重启一下 sshd

sudo systemctl restart sshd.service
sudo systemctl enable sshd.service

新增用户,并添加到sudo 组

adduser xxxx # 推荐全部小写
usermod -aG sudo xxx # 添加到 sudo 组

Refer

  • 阮一峰 ssh
Last Updated:
Contributors: rosendo
Next
github clone