1.使用跳板机连接远程机器

    1. ssh lxc -p 22 -o ProxyCommand='ssh -p 22 ubuntu@hongkong.liuwenwen.net -W %h:%p'

    2.保持SSH连接的稳定性客户端配置

    1. Host *
    2. ServerAliveInterval 30
    3. ServerAliveCountMax 200
    4. TCPKeepAlive yes

    3.ssh强制使用密码

    1. ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com

    4.sshfs挂载和卸载

    1. (base) ubuntu@debian:~$ sshfs user@shenzhen.liuwenwen.net:/ /home/ubuntu/Pictures/shenzhen/ -p 2424
    2. user@shenzhen.liuwenwen.nets password:
    3. (base) ubuntu@debian:~$ fusermount -u /home/ubuntu/Pictures/shenzhen

    5.ssh服务端缺失密钥
    sshd: no hostkeys available — exiting
    解决过程:

    1. ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
    2. ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

    6.ssh计算指纹

    1. ssh-keygen -E sha256 -lf id_rsa

    image.png
    原理:

    1. cat .ssh/id_rsa.pub |
    2. awk '{ print $2 }' | # Only the actual key data without prefix or comments
    3. base64 -d | # decode as base64
    4. sha256sum | # SHA256 hash (returns hex)
    5. awk '{ print $1 }' | # only the hex data
    6. xxd -r -p | # hex to bytes
    7. base64 # encode as base64