A
A
Alexey2020-05-13 11:39:23
SSH
Alexey, 2020-05-13 11:39:23

How to create 2 SSH keys?

Hello!

There is a gulp collector. There is a project. It is necessary that when the project file is changed, it is automatically sent to the ftp server. I use gulp-rsync for this. Each time you make a change, the terminal asks you to enter a password. I read that to bypass this, you need to create an ssh key. Created according to the instructions - everything works.

The problem is that there is another project. And when I create a key for it, it turns out that one overwrites the other. Now the second project does not need a password, the first one does.

I tried to create a key with a different name, but it didn't work. As if some kind of mistake and the password as requested, and asks.

Below is the working code without changing the name:

cd ~/.ssh
ssh-keygen (после этого жму ENTER ENTER ENTER без ввода имени)
scp -p id_rsa.pub [email protected]:~
ssh [email protected]
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cat id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
rm -f ~/id_rsa.pub
logout
eval `ssh-agent -s`
ssh-add


The code I tried to do for a key with a changed name:
cd ~/.ssh
ssh-keygen (после этого ввожу имя id_rsa_COMPANY)
scp -p id_rsa_COMPANY.pub [email protected]:~
ssh [email protected]
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cat id_rsa_COMPANY.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
rm -f ~/id_rsa_COMPANY.pub
logout
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa_COMPANY

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Komchev, 2020-05-13
@KRACKER

Try using one ssh for two projects.
I use one ssh for gulp-rsync and for github

F
FanatPHP, 2020-05-13
@FanatPHP

-i identity_file
Selects a file from which the identity (private key) for RSA or DSA authentication is read.
Just specify explicitly which key to use.
For simplicity/automation, you can use the config file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question