Skip to content

Paswordless SSH

Steps

  • Generate Key
  • put the private key in the .ssh directory of the local machine
  • put the public key in .ssh/authorized_keys directory of the remote machine
  • verify permissions

Script to setup SSH access with a private/public key pair

ssh-keygen -t rsa -b 1024
User=`whoami`
Box=$1

port="-p 10022"
ssh ${User}@${Box} $port "mkdir -p .ssh;chmod 700 .ssh"
cat .ssh/id_rsa.pub | ssh ${User}@${Box} $port 'cat >> .ssh/authorized_keys; chmod 640 .ssh/authorized_keys'

Step by Step

ssh-keygen -t rsa -b 8192
cat .ssh/id_rsa.pub
ssh host
mkdir -p .ssh;chmod 700 .ssh
vi .ssh/authorized_keys
chmod 640 .ssh/authorized_keys

Tags: ssh password certificate key