SSH Passwordless Login Using SSH Keygen in 5 Easy Steps
2014-04-22 15:40
435 查看
SSH(SecureSHELL)isanopensourceandmosttrustednetworkprotocolthatisusedtologinintoremoteserversforexecutionofcommandsandprograms.Itisalsousedtotransferfilesfromonecomputertoanothercomputeroverthe
networkusingsecurecopy(SCP)Protocol.
Inthisarticlewewillshowyouhowtosetuppassword-lessloginusing
sshkeystoconnecttoremoteLinuxserverswithoutenteringpassword.UsingPassword-lessloginwithSSHkeyswillincreasethetrustbetweentwo
Linuxserversforeasyfilesynchronizationortransfer.
IfyouaredealingwithnumberofLinuxremoteservers,then
SSHPassword-lessloginisoneofthebestwaytoautomatetaskssuchasautomaticbackupswithscripts,synchronizationfilesusingscpandremotecommandexecution.
InthisexamplewewillsetupSSHpassword-lessautomaticloginfromserver192.168.1.1asuser
tecmintto192.168.1.2withusersheena.
Step1:CreateAuthenticationSSH-KegenKeyson–(192.168.1.1)
Firstloginintoserver192.168.1.1withuser
tecmintandgenerateapairofpublickeysusingfollowingcommand.
[tecmint@tecmint.com~]$ssh-keygen-trsa
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/home/tecmint/.ssh/id_rsa):[Pressenterkey]
Createddirectory'/home/tecmint/.ssh'.
Enterpassphrase(emptyfornopassphrase):[Pressenterkey]
Entersamepassphraseagain:[Pressenterkey]
Youridentificationhasbeensavedin/home/tecmint/.ssh/id_rsa.
Yourpublickeyhasbeensavedin/home/tecmint/.ssh/id_rsa.pub.
Thekeyfingerprintis:
af:bc:25:72:d4:04:65:d9:5d:11:f0:eb:1d:89:50:4ctecmint@tecmint.com
Thekey'srandomartimageis:
+--[RSA2048]----+
|..oooE.++|
|o.o.o|
|...|
|o..o|
|S..+|
|...o|
|.oo..|
|++|
|+.|
+-----------------+
192.168.1.2usingsheenaasuserandcreate
.sshdirectoryunderit,usingfollowingcommand.[/b]
192.168.1.2undersheena‘s.sshdirectoryasafilename
authorized_keys.
192.168.1.1astecmintuserwithoutpassword.
networkusingsecurecopy(SCP)Protocol.
Inthisarticlewewillshowyouhowtosetuppassword-lessloginusing
sshkeystoconnecttoremoteLinuxserverswithoutenteringpassword.UsingPassword-lessloginwithSSHkeyswillincreasethetrustbetweentwo
Linuxserversforeasyfilesynchronizationortransfer.
IfyouaredealingwithnumberofLinuxremoteservers,then
SSHPassword-lessloginisoneofthebestwaytoautomatetaskssuchasautomaticbackupswithscripts,synchronizationfilesusingscpandremotecommandexecution.
InthisexamplewewillsetupSSHpassword-lessautomaticloginfromserver192.168.1.1asuser
tecmintto192.168.1.2withusersheena.
Step1:CreateAuthenticationSSH-KegenKeyson–(192.168.1.1)
Firstloginintoserver192.168.1.1withuser
tecmintandgenerateapairofpublickeysusingfollowingcommand.
[tecmint@tecmint.com~]$ssh-keygen-trsa
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/home/tecmint/.ssh/id_rsa):[Pressenterkey]
Createddirectory'/home/tecmint/.ssh'.
Enterpassphrase(emptyfornopassphrase):[Pressenterkey]
Entersamepassphraseagain:[Pressenterkey]
Youridentificationhasbeensavedin/home/tecmint/.ssh/id_rsa.
Yourpublickeyhasbeensavedin/home/tecmint/.ssh/id_rsa.pub.
Thekeyfingerprintis:
af:bc:25:72:d4:04:65:d9:5d:11:f0:eb:1d:89:50:4ctecmint@tecmint.com
Thekey'srandomartimageis:
+--[RSA2048]----+
|..oooE.++|
|o.o.o|
|...|
|o..o|
|S..+|
|...o|
|.oo..|
|++|
|+.|
+-----------------+
Step2:Create.sshDirectoryon–192.168.1.2
UseSSHfromserver[b]192.168.1.1toconnectserver192.168.1.2usingsheenaasuserandcreate
.sshdirectoryunderit,usingfollowingcommand.[/b]
[tecmint@tecmint~]$sshsheena@192.168.1.2mkdir-p.ssh
Theauthenticityofhost'192.168.1.2(192.168.1.2)'can'tbeestablished.
RSAkeyfingerprintisd6:53:94:43:b3:cf:d7:e2:b0:0d:50:7b:17:32:29:2a.
Areyousureyouwanttocontinueconnecting(yes/no)?yes
Warning:Permanentlyadded'192.168.1.2'(RSA)tothelistofknownhosts.
sheena@192.168.1.2'spassword:[[b]EnterYourPasswordHere][/b]
Step3:UploadGeneratedPublicKeysto–192.168.1.2
UseSSHfromserver192.168.1.1anduploadnewgeneratedpublickey(id_rsa.pub)onserver192.168.1.2undersheena‘s.sshdirectoryasafilename
authorized_keys.
[tecmint@tecmint~]$cat.ssh/id_rsa.pub|sshsheena@192.168.1.2'cat>>.ssh/authorized_keys'
sheena@192.168.1.2'spassword:[EnterYourPasswordHere]
Step4:SetPermissionson–192.168.1.2
DuetodifferentSSHversionsonservers,weneedtosetpermissionson.sshdirectoryandauthorized_keysfile.[tecmint@tecmint~]$sshsheena@192.168.1.2"chmod700.ssh;chmod640.ssh/authorized_keys"
sheena@192.168.1.2'spassword:[EnterYourPasswordHere]
Step5:Loginfrom192.168.1.1to192.168.1.2ServerwithoutPassword
Fromnowonwardsyoucanloginto192.168.1.2assheenauserfromserver192.168.1.1astecmintuserwithoutpassword.
[tecmint@tecmint~]$sshsheena@192.168.1.2
相关文章推荐
- SSH Passwordless Login Using SSH Keygen in 5 Easy Steps
- 3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
- 3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
- 3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
- To enable ssh root login using password in ESXi 5.5
- 3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
- 3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
- [Ubuntu] Simple method to login SSH without insert user name and password via expect in linux
- SSH key and passwordless login basics for developers
- Passwordless SSH Login
- BI Java 补丁错误处理 :Cannot login to the SAP J2EE Engine using user and password as provided in the Filesystem Secure Store. Enter va
- Passwordless SSH Login
- SSH 无需输密码登陆 passwordless logins using ssh-agent
- 【完美】Your password has expired. To log in you must change it using a client that supports expired pas
- Your password has expired.To log in you must change it using a client that supports expired password
- login with ssh without password
- Android Studio 连接自己搭建的服务器 需要admin 的帐号的问题 SSH Password Login,please enter password for user git@git.
- Your password has expired. To log in you must change it using a client that supports expired passwor
- Your password has expired.To log in you must change it using a client that supports expired password
- ssh另一台机器时,报Password authentication is disabled to avoid man-in-the-middle attacks.