LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2019, 05:49 AM   #61
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by michaelk View Post
Does your home desktop have an authorized_keys file?
yes ( i believe I did this when i was learning/testing connection between home_desktop and home_laptop, box B and C)

Unless, the public key from box A (work_desktop) did not append correctly (i thought I double checked I was appending it correctly).

Last edited by however; 02-06-2019 at 05:53 AM.
 
Old 02-06-2019, 05:54 AM   #62
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,737

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
Unless the private key does not match the public key in your authorized_keys file.
 
Old 02-06-2019, 06:08 AM   #63
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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.

Shall i do the process again?
 
Old 02-06-2019, 06:13 AM   #64
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
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.
 
Old 02-06-2019, 06:19 AM   #65
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
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?
 
Old 02-06-2019, 07:36 AM   #66
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,737

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
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.
 
Old 02-06-2019, 08:49 AM   #67
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Thnaks michalek,
msg received (i think i did a litle salad with creting &recreating keys).
So, i will fix it and let you know
 
Old 02-08-2019, 05:28 AM   #68
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Red face

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$
Any ideas what i am doing wrong?
 
Old 02-08-2019, 05:46 AM   #69
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Just going by the error message, I'd say that the path is off or the key itself is missing at the end of that path.

Code:
ls /homepath_dir/.ssh/id_rsa
test -f /homepath_dir/.ssh/id_rsa || echo "Oh teh noes!"
 
Old 02-08-2019, 06:00 AM   #70
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,737

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
Quote:
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.
 
Old 02-08-2019, 08:25 AM   #71
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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.

Last edited by however; 02-08-2019 at 08:34 AM.
 
Old 02-08-2019, 08:53 AM   #72
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,737

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
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

Last edited by michaelk; 02-08-2019 at 08:57 AM.
 
Old 02-08-2019, 09:06 AM   #73
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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?
 
Old 02-08-2019, 09:21 AM   #74
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,737

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
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
 
Old 02-08-2019, 10:18 AM   #75
however
Member
 
Registered: Jan 2019
Distribution: slackware current
Posts: 497

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
3 Ubuntu boxes with Samba - One finds all XP shares - Two UltraSparc64 boxes do not mwx Linux - Server 1 01-28-2009 06:03 AM
connecting two slackware linux boxes with an ethernet cable riodeuno Linux - Networking 3 12-17-2008 11:56 PM
connecting two linux boxes together jeffbk Linux - Networking 2 05-08-2007 12:12 PM
Connecting two linux boxes via cross cable ElPuello Linux - Networking 4 11-10-2004 10:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration