linux下SSH无密码登录

把windows下的.ppk文件转成linux下的openssh key(实现无密码登录):

---------------

Do it with Putty.

  • Linux: with your package manager look for the putty alternative:

    • Debian like apt-cache search putty
    • RPM based yum list putty
    • Gentoo emerge --search putty
    • etc.
  • OS X: Install Homebrew, then run brew install putty

Place your keys in some directory, e.g. your home folder. Now convert the PPK keys to SSH keypairs:

cd ~
puttygen id_dsa.ppk -O private-openssh -o id_dsa

for the private key, and

puttygen id_dsa.ppk -O public-openssh -o id_dsa.pub

or the public key. Move these keys to ~/.ssh and make sure the permissions are set to private for your private key:

mkdir -p ~/.ssh
mv -i ~/id_dsa ~/.ssh
mv -i ~/id_dsa.pub ~/.ssh
chmod 600 ~/.ssh id_dsa

---------------

参考:http://superuser.com/questions/232362/how-to-convert-ppk-key-to-openssh-key-under-linux


多个server key的解决办法(config文件)

--------------------

Pointing to the Key

The only problem now, is that when ssh searches for a key, it won’t be able to find the one it’s looking for. You need to correctly edit your config file that should be located in your ~/.ssh/ folder. If it isn’t already there, just create a new file.

Mine looks like the following:

Host github.com
	User git
	Hostname github.com
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/git/id_rsa
Host fedoraproject.org
	Hostname fedoraproject.org
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/fedoraproject/id_rsa
Host fedorapeople.org
	Hostname fedorapeople.org
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/fedoraproject/id_rsa

It’s fairly self-explanatory what each part of the file is, you could even just use mine as a template.

--------------

参考:http://www.robotgoblin.co.uk/blog/2012/07/24/managing-multiple-ssh-keys/


---------------

UPDATE:

遇到的问题:config里Host项可以写域名,也可以写IP,但是,ssh 域名登录时,config的Host就必须是域名, ssh IP登录时, config的Host就必须是IP。


你可能感兴趣的:(linux下SSH无密码登录)