ssh - password prompt keep on coming on the console -
i wrote below command, copy id_dsa.pub
file other server part of auto login feature. every time below message coming on console:
spawn scp -o stricthostkeychecking=no /opt/mgtservices/.ssh/id_dsa.pub root@12.43.22.47:/root/.ssh/id_dsa.pub password: password:
below script wrote this:
function sshkeygenerate() { if ! [ -f $home/.ssh/id_dsa.pub ] ;then expect -c" spawn ssh-keygen -t dsa -f $home/.ssh/id_dsa expect y/n { send y\r ; exp_continue } expect passphrase): { send \r ; exp_continue}expect again: { send \r ; exp_continue} spawn chmod 700 $home/.ssh && chmod 700 $home/.ssh/* exit " fi expect -c"spawn scp -o stricthostkeychecking=no $home/.ssh/id_dsa.pub root"@"12.43.22.47:/root/.ssh/id_dsa.pub expect *assword: { send $rootpwd\r }expect yes/no { send yes\r ; exp_continue } spawn ssh -o stricthostkeychecking=no root"@"12.43.22.47 \"chmod 755 /root/.ssh/authorized_keys\" expect *assword: { send $rootpwd\r }expect yes/no { send yes\r ; exp_continue } spawn ssh -o stricthostkeychecking=no root"@"12.43.22.47 \"cat /root/.ssh/id_dsa.pub >> /root/.ssh/authorized_keys\" expect *assword: { send $rootpwd\r }expect yes/no { send yes\r; exp_continue } sleep 1 exit" }
you should first create passwordless ssh destination server, won't need enter password while scp.
assuming 192.168.0.11 destination machine:
1) ssh-keygen -t rsa
2) ssh sheena@192.168.0.11 mkdir -p .ssh
3) cat .ssh/id_rsa.pub | ssh sheena@192.168.0.11 'cat >> .ssh/authorized_keys'
4) ssh sheena@192.168.0.11 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"
link refernce:
http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
Comments
Post a Comment