说白了就是ssh秘钥配置,第一次感觉晕乎乎的,做过几次之后命令就会背了,也是so easy!
First Step:
在自己的服务器上创建ssh秘钥
ssh-keygen
会输出以下内容,直接回车回车回车就行
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
8c:2a:ed:82:98:6d:12:0a:3a:ba:b2:1c:c0:25:be:5b
Second Step:
把公钥拷贝到远程服务器,使用下面的这个命令可以直接拷贝下来会传输到你的home 目录下(个人主机可能就是~目录),然后创建你自己 authorized_keys 文件,内容就是你的公钥文件。那个.pub的文件
ssh-copy-id -i ~/.ssh/id_rsa.pub UserName@RemoteServer
执行命令会输出
UserName@RemoteServer's password: ********
Now try logging into the machine, with "ssh 'username@remoteserver'", and check in:
~/.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.