LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   ssh keygen copy between 2 PC where logins are different - does it make sense? (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/ssh-keygen-copy-between-2-pc-where-logins-are-different-does-it-make-sense-4175675313/)

DeanAnderson 05-15-2020 09:43 AM

ssh keygen copy between 2 PC where logins are different - does it make sense?
 
Hi
I have ssh keygen generated on one PC which looks something like that:

Code:

ssh-rsa BDFdasadsdsds
ssadffdsfdsfdssdfds
dsds/sdsdssasaasasa
ssassad my_login1@something.net

I have on this PC ./ssh/known_hosts list fulfilled as PC has been used for a few years.
Then I have another second new PC2. Unfortunately I made mistake on another PC2 - when I was installing ubuntu I created another login than on first PC, let's say it is my_login2. However I will try to add second login to PC2 called my_login with root privelages. If I succeed the question is:

Can I copy now keygen and known_hosts from first PC to second PC2 and will it work? The important thing is also that part after @ is different. On PC1 it is something.net and on PC2 it is somethingother.net. Despite this fact will it work?

Another problem is that it is not so easy to create second account on PC2 with root privelages. I created with command:
sudo usermod -aG sudo my_login
and I have many issues, for example:
ls /media/sf_shared
ls: cannot open directory '/media/sf_shared': Permission denied

dc.901 05-15-2020 10:00 AM

I may be misunderstanding your question...
For example, you have:
userA on PC1
userB on PC2

You can copy content of public key (file that ends in .pub) into authorized_keys file.

This will allow password-less login to work between users and PCs.

DeanAnderson 05-15-2020 10:02 AM

OK I thought that logins have to be the same.
I will try just when they are different and let's see if it works.

Comment:
It doesn't work. This login is important. I got:

Code:

my_login2@something.net:~/work$ git clone -b folder ssh://gerrit.someaddress:port/somepath
Cloning into 'folder'...
my_login2@gerrit.someaddress: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The problem is with login. It have to be my_login. What my alternatives are?
- install ubuntu system from the beginning now with proper login the same as on first PC and in keygen - a lot of work
- generate new keygen and add it to tens of servers gitlab, gerrit - I would like to avoid this one as a lot of work
- create second account on PC2 with proper login, but there are a lot of problem with lack of access for example to /media/sf_shared
- any better idea? Keep in mind that I use also bitbake so any modification to this command (explicity set login) can't be done:
git clone -b folder ssh://gerrit.someaddress:port/somepath
as this is how bitbake use it without explicity set login.

dc.901 05-15-2020 10:40 AM

Just try simple SSH first:

Code:

ssh <username>@<hostname>

dc.901 05-15-2020 10:42 AM

If the username is different, then you will have to specify that:

Code:

git clone -b folder ssh://<username>@gerrit.someaddress:port/somepath

scasey 05-15-2020 12:41 PM

AFAIK, ssh keys identify computers and users. They aren't transferable. One needs a key for each user and 'puter.


All times are GMT -5. The time now is 04:29 PM.