Настроим беcпарольный вход по ssh (подойдет для scp, sftp) на удаленный сервер remoteserv.ru под пользователем root (хотя советую именно root не использовать).
Если имя вашего локального пользователя совпадает с удаленным, то root@ везде можно опустить.
Установка
Cоздаем открытый и закрытый ключ нашей локальной системы (на все вопросы отвечаем «enter»)
[root@home]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 49:e4:9d:90:0u:fe:80:ac:90:0e:b8:ff:1e:da:53:35 root@home.ru The key's randomart image is: +--[ RSA 2048]----+ | . . .o+E. | |. + ..+.+ . | | + . .o o o | |. . . +E. | | . .o . | | . | | = o | | . = | | . | +-----------------+ [root@home]#
Настраиваем удаленную систему на то, что бы она авторизировала ssh по открытому ключу
[root@home ~]# ssh-copy-id -i ~/.ssh/id_rsa root@remoteserv.ru The authenticity of host 'remoteserv.ru (192.193.194.195)' can't be established. RSA key fingerprint is df:2e:65:bd:g7:33:da:90:d8:t7:37:bb:18:a9:5c:0f. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'remoteserv.ru,192.193.194.195' (RSA) to the list of k nown hosts. root@remoteserv.ru's password: [root@home ~]#
Можно пробовать авторизоваться без пароля:
[root@home ~]# ssh -l root remoteserv.ru Linux cs 2.6.32-34-generic-pae #77-Ubuntu SMP Tue Sep 13 21:16:18 UTC 2011 i686 GNU/Linux Ubuntu 10.04.3 LTS ........куча информации, вам не интересной...................... root@remoteserv:~$
всё!
Возможные ошибки:
[root@home]# ssh-copy-id -i ~/.ssh/id_rsa root@remoteserv.ru -bash: ssh-copy-id: command not found [root@home]#
[root@home]# ssh root@remoteserv.ru -bash: ssh: command not found [root@home]#
[root@home]# scp root@remoteserv.ru -bash: scp: command not found [root@home]#
Решение:
yum install openssh-clients
Если в системе ssh-copy-id не нашлось…
Копируем самостоятельно открытый ключ на удаленную систему
scp ~/.ssh/id_rsa.pub root@remoteserv.ru
Заходим на удаленный сервер
ssh root@remoteserv.ru
Проверим есть ли директория .ssh и при её отсутствии создадим и назначим нужные права
[ -d ~/.ssh ] || (mkdir ~/.ssh; chmod 711 ~/.ssh)
Добавляем открытый ключ к авторизированым ключам
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
Устанавливаем нужные права
chmod 600 ~/.ssh/authorized_keys
Удаляем ненужное
rm ~/id_rsa.pub
Проверяем
ssh root@remoteserv.ru
Свежие комментарии