在工作中,ssh登录远程机器是我们经常用的一个命令,偶尔也会使用ssh-keygen生成一下秘钥。对于ssh的使用,对于不明白的地方,我们可以使用man ssh查看各个参数的作用。
下面列举了几个常用的使用,方便日后查阅。
ssh 秘钥生成
ssh-keygen -t rsa
-t = The type of the key to generate
密钥的类型
-C = comment to identify the key
用于识别这个密钥的注释
注释你可以输入任何内容,很多网站和软件用这个注释作为密钥的名字
ssh登录指定秘钥登录:
ssh -i key.pem root@192.168.1.1
ssh 别名登录(效率神器)
.ssh/config 这是配置别名的地方
Host *
ServerAliveInterval 60
Host denglu
HostName 你的ip
User mojie
IdentityFile ~/.ssh/你的pem文件名.pem
ssh-copy-id 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./ssh , 和 ~/.ssh/authorized_keys的权利
ssh-add -L 可以通过man ssh-add 查看命令参数含义
-L Lists public key parameters of all identities currently represented by the agent.
-l Lists fingerprints of all identities currently represented by the agent.
使用详细介绍文章
https://blog.csdn.net/liu_qingbo/article/details/78383892
###ssh-add与多账户
https://segmentfault.com/q/1010000000835302