ssh private key

来源:互联网 发布:wubi安装ubuntu 编辑:程序博客网 时间:2024/05/02 03:04

login server without password

  1. generate key (on my own computer)

    ssh-genkey -t rsa -f rsa_name
    (have to change the name of key, otherwise it will override the old one)

  2. put the public key to the server
    For example, the keys are called id_rsa_xx(private key) and id_rsa_xx.pub(public key)

    scp id_rsa_xx.pub server
    cd /server/.ssh
    cat id_rsa_xx.pub >> ~/.ssh/authorized_keys (if not, rename it to authorized_keys)

  3. If there are multiple private keys in our own computer, modify ~/.ssh/config

    vim config

    Host servername
    User username
    IdentityFile ~/.ssh/id_rsa_xx

  4. Make sure ~/.ssh dir and ~/.ssh/authorized_keys on the remote machine must be writable only by you ( ref ). 700 or 755, but not 775

It works now

0 0
原创粉丝点击