paddingme / paddingme.github.io

my github pages
http://padding.me
4 stars 2 forks source link

ssh生成公钥 #9

Open paddingme opened 8 years ago

paddingme commented 8 years ago

1 本地生成公钥和私钥

这里命名为 test( 生成之后公钥为 test.pub 私钥 test 位于 ~/.ssh 下)

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/paddingme/.ssh/id_rsa): test
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in test.
Your public key has been saved in test.pub.
The key fingerprint is:

2 发送公钥到远程服务器上

$ ssh-copy-id remoteUser@remoteHost

3 测试是否可以免密登录

$ssh remoteUser@remoteHost

不行的话

登录远程服务器 vim /etc/ssh/sshd_config 找到 以下三行去行首#号

  RSAAuthentication yes
  PubkeyAuthentication yes
  AuthorizedKeysFile .ssh/authorized_keys

保存退出

ok!再测试

paddingme commented 7 years ago

测试