# ssh-keygen -t rsa -P ” -f ~/.ssh/id_rsa
-P ”: 密钥文件不加密，缺省不加密，但需要额外敲回车。
# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa Generating public/private rsa key pair. Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: a4:2d:6d:31:79:c2:a1:f4:66:e0:3b:77:c6:17:d0:ca [MD5] root@linux-t7tx The key's randomart image is: +--[ RSA 2048]----+ | o . .. | | o = o .. | | o @.... | | O *E . | | = S + . | | = o . | | | | | | | +--[MD5]----------+
# ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'email@example.com'" and check to make sure that only the key(s) you wanted were added.
# ssh -i ~/.ssh/id_rsa firstname.lastname@example.org "echo Hello" Hello -i: 指定私钥的位置，缺省路径就是：~/.ssh/id_rsa，也就是说，如果密钥的存放位置默认的话，无需指定。 # ssh email@example.com "echo Hello" Hello