Avatar

Organizations

2 results for Ssh
  • 生成新的 SSH Key

    ssh-keygen -t rsa -b 4096 -C "[email protected]"
    ...
    Enter a file in which to save the key (/home/you/.ssh/algorithm): <key_name>
    Enter passphrase (empty for no passphrase): [输入密码]
    Enter same passphrase again: [再次输入密码]
    

    将新的 SSH Key 添加到 Github

    1. 将公钥文件的内容COPY出来
    cat ~/.ssh/<key_name>.pub
    
    1. Github.com -> “Settings” -> “SSH and GPG keys” -> “New SSH key”

    Title : 为新密钥添加描述性标签 Key : 粘贴COPY的公钥内容

    1. “Add SSH key”

    使用 SSH 连接到 Github

    1. ssh config
    cd ~/.ssh
    # 设置访问权限
    chmod 600 <key_name>
    # 生成SSH配置文件
    cat > config << EOF
    Host github.com
      Hostname ssh.github.com
      Port 443
      IdentityFile ~/.ssh/<key_name>
      UpdateHostKeys yes
      Compression yes
      User git
    EOF
    
    1. 连接测试
    ssh -T [email protected]
    ...
    Are you sure you want to continue connecting (yes/no)? <yes>
    ...
    Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
    

    自动验证

    如果找不到软件,直接下载安装 或 更换软件源 Linux 版本库管理

    ssh keychain github git Created Tue, 21 Jun 2022 19:20:04 +0800
  • 初始化配置

    # 配置时区
    timedatectl set-timezone Asia/Shanghai
    
    # 关闭邮件服务
    systemctl stop [email protected] \
    ; systemctl disable [email protected]
    
    # 配置Shell提示符
    echo "PS1='\[\e[36;40m\][\D{%Y-%m-%d} \A] \[\e[0m\] \[\e[35;40m\]\w\[\e[0m\]\n\[\e[33;40m\][\u@\H]\[\e[0m\] \\$ '" >> ~/.bashrc
    # 打开自定义命令
    sed -E -i.bak \
        -e '/(export|eval|alias (ls|ll|l|rm|cp|mv))/s/^# //' ~/.bashrc \
        && . ~/.bashrc
    
    # 配置 sshd
    # 允许root密码登录
    # 允许密码登录
    # 解决SSH自动断开问题
    sed -E -i.bak \
        -e 's/#(Port 22)/\1/' \
        -e 's/#(PermitRootLogin) prohibit-password/\1 yes/' \
        -e 's/#(PubkeyAuthentication yes)/\1/' \
        -e 's/#(PasswordAuthentication yes)/\1/' \
        -e 's/#(AllowTcpForwarding yes)/\1/' \
        -e 's/(X11Forwarding yes)/#\1/' \
        -e 's/#(Compression delayed)/\1/' \
        -e 's/#(ClientAliveInterval) 0/\1 60/' \
        -e 's/#(ClientAliveCountMax) 3/\1 3/' \
        /etc/ssh/sshd_config \
        && systemctl restart sshd.service
    

    软件更新

    软件库管理

    CLI bash ssh top linux Created Mon, 17 Jan 2022 11:07:07 +0800