28
Июн
0

Доступ к серверу SSH c ключами, без пароля

Создание ключа

ssh-keygen -t rsa

/home/serge/.ssh/id_rsa

создал два файла: id_rsa и id_rsa.pub

______

Настройка SSH sshd_config

# Should we allow Identity (SSH version 1) authentication?
RSAAuthentication yes

# Should we allow Pubkey (SSH version 2) authentication?
PubkeyAuthentication yes

# Where do we look for authorized public keys?
# If it doesn’t start with a slash, then it is
# relative to the user’s home directory
AuthorizedKeysFile    .ssh/authorized_keys

_________

# Copy the RSA Pubkey to the server using scp.
# You can use any method you like, including using
# copy/paste if it’s convenient.
my$ cd $HOME/.ssh
my$ scp id_rsa.pub ssh-server:id_rsa_my.pub
serge@ssh-server’s password: (enter password)

# Now let’s log in and create the authorized_keys file
my$ ssh ssh-server
serge@ssh-server’s password: (enter password)

# Create the .ssh dir if it doesn’t already exist
ssh-server$ mkdir .ssh
ssh-server$ chmod 700 .ssh
ssh-server$ cd .ssh

# Concatenate the RSA Pubkey we just uploaded to
# the authorized_keys file.  (This will create
# if it doesn’t already exist.)
ssh-server$ cat ../id_rsa_my.pub >> authorized_keys

# Make sure permissions are paranoid
ssh-server$ chmod 600 authorized_keys

Возможно перенос ключа с записью в соответствующие файлы по команде

ssh-copy-id  login@server

 

Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.

Comments are closed.

Celadon theme by the Themes Boutique