linux下怎样设置ssh无密码登录

如题所述

第1个回答  2015-06-22
有两种方法,可以用证书实现无密码登录,或者sshpass命令可以指定ssh登陆密码。
1、派出间谍
Step 1:执行ssh-keygen -t rsa,会在~/.ssh下生成两个文件,id_isa和id_isa.pub
On one of the local LINUX (not SGI) machines, generate an id_rsa and id_rsa.pub pair as follows (this machine will subsequently be referred to as your home machine):
ssh-keygen will create the files ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub.
Step 2: Copy the contents of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys on any and all machines to which you want to be able to ssh to without being prompted for a password
可以用下面的命令完成此步骤:
cat id_rsa.pub |ssh [email protected] ‘cat ->> ~/.ssh/authorized_keys’
2、用sshpass程序
安装:
tar zxf sshpass-1.05.tar.gz
cd sshpass-1.05
./configure;make;make install
which sshpass
/usr/local/bin/sshpass
实例:
sshpass -p “passwd” ssh root@ip本回答被提问者和网友采纳
相似回答