SSH without password, and key only login

# create rsa key, skip if already done
local> ssh-keygen -t rsa

# create .ssh/ in home
local> ssh USER@REMOTEHOST mkdir ~/.ssh

# cat local public key, pipe over to ssh, take the piped local key append into remote ~/.ssh/authorized_keys
local> cat ~/.ssh/ | ssh USER@REMOTEHOST 'cat >> ~/.ssh/authorized_keys'

# now on remote
remote> sudo vim /etc/ssh/sshd_config
# add the following
PermitRootLogin no # disable ssh as root
PubkeyAuthentication yes # use key authentication
PasswordAuthentication no # disable password authentication

Leave a Reply