Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Unless the private key does not match the public key in your authorized_keys file.
I was led to believe that I can have multiple public keys in the authorized_keys file, so I just "ssh-copy-id -i ~/.ssh home_desktop@192.168.0.xxx" the id_rsa.pub from box A
I was asked for confirmation to overwrite the already existing authorized_keys file (on box B, home desktop) but before accepting i viewed file-Kompare and it confirmed that the file had only one key and it would contain two keys after confirmation.
You can have multiple public keys in the auauthorized_keys file, and it's usually a good idea. It's also a good idea to use separate names for the private keys, not just id_rsa, because once you have more than one key pair you have to keep them separate. So I'd recommend trying the process again.
You can have multiple public keys in the auauthorized_keys file, and it's usually a good idea. It's also a good idea to use separate names for the private keys, not just id_rsa, because once you have more than one key pair you have to keep them separate. So I'd recommend trying the process again.
that makes perfect sense (afterall, computers are not so intelligent)
and i guess, it would be enough to rename the keys pair on box A (work pc) to something else? i.e.:
Code:
mv id_rsa.pub workid_rsa.pub
mv id_rsa workid_rsa
and then repeat the "ssh-copy-id -i" process; correct?
If your trying to login on localhost then just append the public key to authorized_keys file in your user's .ssh directory. It would help to keep the keys straight since all keys are named id_rsa. If you created more then one set of keys on the same computer then it is possible the public key in the authorized_keys file does not match anymore.
If using keys with different names then a .ssh/config helps to keep things organized.
Frustrating!
I have deleted the authorized_keys files on box A (work_desktop) and B (home_desktop).
Rerecreated new keys_pair, (A: workid_rsa and workid_rsa.pub and B id_rsa and id_rsa.pub)
Copied id_rsa.pub to work desktop and. workid_rsa.pub to home desktop (so i should have been able to connect back and forth AB-BA)
Made sure config files on A and B are correct (i think)
Code:
Box A, (work)
Host home_desktop
HostName home_public_ip
User home_desktop_user
IdentitiesOnly yes
IdentityFile /homepath_dir/.ssh/id_rsa
and box B, (Home)
Host work_desktop
HostName work_public_ip
User work_user
IdentitiesOnly yes
IdentityFile /workpath_dir/.ssh/workid_rsa
and still when i try to connect A and B, i get:
Code:
bash-4.2$ ssh home_desktop
no such identity: /homepath_dir/.ssh/id_rsa: No such file or directory (i'm pretty sure the file IS there)
Permission denied (publickey,keyboard-interactive).
and if i try using the home_public_ip i get:
bash-4.2$ ssh home_public_ip
Permission denied (publickey,keyboard-interactive).
bash-4.2$
Rerecreated new keys_pair, (A: workid_rsa and workid_rsa.pub and B id_rsa and id_rsa.pub)
Copied id_rsa.pub to work desktop and. workid_rsa.pub to home desktop
It appears that you created the workid keys on the work computer and id keys on the home computer which means the config file IdentityFile keys are backwards.
It appears that you created the workid keys on the work computer and id keys on the home computer which means the config file IdentityFile keys are backwards.
so, the config file in box A should have:
Host home_desktop (the name of the pc I want to connect to, box B)
HostName home_public_ip (the public IP address of the pc i want to connect to, box B)
User home_desktop_user (the username of the pc i want to connect to box B)
IdentitiesOnly yes
IdentityFile /homepath_dir/.ssh/id_rsa (and the id_rsa file of the pc I am connecting from, box A)
kinda doesnt make senze. NOt sure I understood it right.
Lets go through an example with the basic steps.
If you want to login to your home computer i.e B (server in this case) from your work computer i.e A (client in this case).
Typically the keys are created on the client and the public key is copied to the server using ssh-copy-id script.
1. On your work computer (client) you would use the ssh-keygen program to create a key pair in your ~/.ssh using rsa protocol which is the default and name it home. The private key is called home and the public key is called home.pub
2. Using the ssh-copy-id script you would copy the public key home.pub to your home computer A (server). The ssh-copy-id script appends the public key home.pub to the specified server's username i.e. /home/home_desktop_user/.ssh/authorized_keys file.
3. You should be able to login from the command line using the private key. On your work computer you would run the command
ssh -i ~/.ssh/home home_desktop_user@home_public_IP
The config file on your work computer would then be
Host home_desktop
HostName home_public_ip
User home_desktop_user
IdentitiesOnly yes
IdentityFile ~/.ssh/home
To login to the home computer via the config file run the command:
ssh home_desktop
Lets go through an example with the basic steps.
If you want to login to your home computer i.e B (server in this case) from your work computer i.e A (client in this case).
Typically the keys are created on the client and the public key is copied to the server using ssh-copy-id script.
1. On your work computer (client) you would use the ssh-keygen program to create a key pair in your ~/.ssh using rsa protocol which is the default and name it home. The private key is called home and the public key is called home.pub
2. Using the ssh-copy-id script you would copy the public key home.pub to your home computer A (server). The ssh-copy-id script appends the public key home.pub to the specified server's username i.e. /home/home_desktop_user/.ssh/authorized_keys file.
3. You should be able to login from the command line using the private key. On your work computer you would run the command
ssh -i ~/.ssh/home home_desktop_user@home_public_IP
The config file on your work computer would then be
Host home_desktop
HostName home_public_ip
User home_desktop_user
IdentitiesOnly yes
IdentityFile ~/.ssh/home
To login to the home computer via the config file run the command:
ssh home_desktop
i did EXACTLY as you mentioned a part from the home. what is that supposed to be replaced with? Home path? home username? home_id file?
home is just them name of the key file. From what you posted you created on your work computer workid_rsa and workid_rsa.pub. So replace home with workid_rsa
home is just them name of the key file. From what you posted you created on your work computer workid_rsa and workid_rsa.pub. So replace home with workid_rsa
then, I have done it identical to what you instructed.
Port 22 is open on both pcs. The only thing that differs is the distro version:
box A, work desktop runs Slackware14.1(32b) and
box B, home desktop runs Slackware14.2(64b). and,
Code:
box A
ssh-V
OpenSSH_6.3p1, OpenSSL 1.0.1e 11 Feb2013
box B
ssh-V
OpenSSH_7.9p1, OpenSSL 1.1.1a 20 Nov 2018
p.s.: this time i created the keys only once after complete ~/.ssh folder clean up and both my "authorized_keys" and "config" files have only one entry each
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.