打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Login without password! (ssh a remote computer)

Have you ever gotten tired of constantly entering your password whenever ssh’ing a remote computer? You don’t need to! You can create a pair of SSH keys, namely a private and public one, which will save you from re-entering your password in the future. The private key you keep secret in your home folder and the public key you copy to every server or remote computer which you wish to SSH. The authentication then proceeds as follows: when you wish to SSH a remote computer, their public key is then compared with your private key and if they match, then the authentication succeeds. Let’s proceed with how we create SSH keys

Step-by-step guide

  1. Create SSH Keys with ssh-keygen
  2. Transfer the public key with ssh-copy-id command
  3. Login without Password

 

1. Create SSH Keys with ssh-keygen

Open up a terminal and type ssh-keygen

lindon@michael-laptop:~$ ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/home/lindon/.ssh/id_rsa):  Created directory '/home/lindon/.ssh'.Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/lindon/.ssh/id_rsa.Your public key has been saved in /home/lindon/.ssh/id_rsa.pub.

When prompted to enter a file, passphrase, same passphrase, simply press return – we don’t want to enter anything here. The last line will then be succeeded  by the key’s fingerprint and random image. You’ll notice that the public and private key are found in the /home/user/.ssh    folder (it’s hidden so make sure you can view hidden folders). The next step is to copy the public key over to the remote computer…

 

2.Transfer the public key with ssh-copy-id command

Syntax: ssh-copy-id [-i [identity_file]] [user@]machine

lindon@michael-laptop:~$ ssh-copy-id -i lindon@remotecomputer.comThe authenticity of host 'remotecomputer (66.147.244.84)' can't be established.RSA key fingerprint is   :  :  :  :  :  :  :  :  :  :  :  :  :  :  :  :.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'remotecomputer,66.147.244.84' (RSA) to the list of known hosts.lindon@remotecomputer's password:Now try logging into the machine, with "ssh 'lindon@remotecomputer.com'", and check in:~/.ssh/authorized_keysto make sure we haven't added extra keys that you weren't expecting.lindon@michael-laptop:~$

The -i option means that the default public key, i.e. ~/.ssh/id_rsa.pub, is used.

3. Login without Password

lindon@michael-laptop:~$ ssh lindon@remotecomputer.comWelcome to Ubuntu 11.04 (GNU/Linux 2.6.38-11-generic x86_64)* Documentation:  https://help.ubuntu.com/Last login: Sun Sep 11 15:57:14 2011 from 66.147.244.84lindon@remotecomputer:~$

And there we go, login without password!

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
利用ssh-keygen生成密钥对
Password-less logins with OpenSSH
sshpass 用法举例
交换机配置 ssh 登陆 | 千月
gitlab使用ssh一直提示Permission denied的问题
SSH简单原理及在CiscoIOS设备上启用SSH
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服