LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-12-2018, 11:51 AM   #1
Adirondacks
Member
 
Registered: Oct 2018
Posts: 98

Rep: Reputation: 0
Naming Public-Key on Server


This is regarding setting up passwordless authentication for SSH.

Locally when I run ssh-keygen, I tend to use the naming convention: <company_initials>_id_rsa

For example:

abc_id_rsa
abc_id_rsa.pub

def_id_rsa
def_id_rsa.pub


My wanting to do this is to make key-pair for different servers more easily identifiable.

I have been told that it is okay to make such a change, and it has no impact on the internals of the public/private keys, but that I do need to specify the non-standard name when doing things like SSH'ing into my server.

For instance, I would need to specify this...

Code:
ssh -i ~/.ssh/abc_id_rsa user1@111.222.333.444 -p 22

So finally on to my question...

Being a newbie, I use cPanel to import my Public-Key onto my server.

In cPanel, under the heading "Import SSH Key", is a webform asking for...

- Choose a name for this key
- Paste the private key into the following text box
- Passphrase
- Paste the public key into the following text box


Questions:
1.) When I generated my key-pair, if I used the naming convention above, would I break things if in cPanel I named my Public-Key the default of "id_rsa.pub"?


2.) If I name the Public-Key "abc_id_rsa.pub" do I have to make any changes anywhere else, or will that work?


3.) Should I be including the ".pub" on the end, or is that implied for a Public-Key?


Thanks!
 
Old 10-12-2018, 12:42 PM   #2
nodir
Member
 
Registered: May 2016
Posts: 222

Rep: Reputation: Disabled
3) The *pub key is the one which gets put on the remote in the file ~/.ssh/authorized_keys, either copied manually or with ssh-copy-id (or similar command)

2) You don't have to make that change but for convenience you can create a file ~/.ssh/config
Code:
host abc
hostname abc.org
user username
port 22
#ServerAliveInternal 30
ServerAliveCountMax 100
IdentityFile ~/.ssh/abc_id_rsa
Now you can just use "host abc" (whichever you have choosen as a shortcut !)
ssh abc
rsync -auv ~/Downloads abc:Tmp/
git, sshfs, etc ... you will always be able to use the shortcut: "abc" which you have choosen for the user@hostname with the IdentityFile ...
 
1 members found this post helpful.
Old 10-12-2018, 01:00 PM   #3
Adirondacks
Member
 
Registered: Oct 2018
Posts: 98

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nodir View Post
3) The *pub key is the one which gets put on the remote in the file ~/.ssh/authorized_keys, either copied manually or with ssh-copy-id (or similar command)
Right.



Quote:
Originally Posted by nodir View Post
2) You don't have to make that change but for convenience you can create a file ~/.ssh/config
Code:
host abc
hostname abc.org
user username
port 22
#ServerAliveInternal 30
ServerAliveCountMax 100
IdentityFile ~/.ssh/abc_id_rsa
You lost me on how to create that file...

I am actually a Mac user. Could I create a file like that in BBEdit and then save it to: ~/.ssh/config

Is "config" the name of the file I would be creating?

Does that file already exist? (Don't want to overwrite anything!)



Quote:
Originally Posted by nodir View Post
Now you can just use "host abc" (whichever you have choosen as a shortcut !)
ssh abc
rsync -auv ~/Downloads abc:Tmp/
git, sshfs, etc ... you will always be able to use the shortcut: "abc" which you have choosen for the user@hostname with the IdentityFile ...
I don't understand what to type?

What is rsynch?

Here is my original command I am used to running in Terminal...

Code:
ssh -i ~/.ssh/abc_id_rsa user1@111.222.333.444 -p 22
How would I modify that command after takin your advice?
 
Old 10-12-2018, 01:22 PM   #4
nodir
Member
 
Registered: May 2016
Posts: 222

Rep: Reputation: Disabled
On Linux and BSD systems:
"config" is the name of the file
"~/.ssh/config" is the path
if it exists, you don't overwrite, you append another entry.
Hence you then simply use, without -i :
ssh abc
ssh another_remote
ssh still_another_remote
So you just use whatver name you have choosen for your convinience as the first entry (name abc; the abc part).
Code:
host abc_convenient_name
hostname 111.222.333.444
user user1 
port 22 
ServerAliveCountMax 100
IdentityFile ~/.ssh/abc_id_rsa
Now you simply do:
Code:
ssh abc_convenient_name
(abc_convenient_name not being that convenient ... ).
rsync is just one example of a program based on ssh. All programs based on ssh will make use of ~/.ssh/config, so you will save yourself a lot of typing.

Last edited by nodir; 10-12-2018 at 01:24 PM.
 
Old 10-12-2018, 01:52 PM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,327
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
I'd tweak that slightly, including indentation for readability.

Code:
Host 444 111.222.333.444
        HostName 111.222.333.444
        User user1 
        Port 22 
        IdentityFile ~/.ssh/abc_id_rsa
        IdentitiesOnly yes

Host *
        ServerAliveInterval 30
        ServerAliveCountMax 4
See "man ssh_config" for the details, but that would allow either

Code:
ssh 444
or

Code:
ssh 111.222.333.444
and the SSH client would fill in port, user, key file, etc. automatically.
 
1 members found this post helpful.
Old 10-12-2018, 02:47 PM   #6
Adirondacks
Member
 
Registered: Oct 2018
Posts: 98

Original Poster
Rep: Reputation: 0
For now, I think I like the extra typing as it helps me learn the Linux command-line and better understand what I need to tell Linux/SSH to do.

But down the road that would be handy!

Thanks, @Nodir and @Turbocapitalist
 
  


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
SSH skips public key authentication for a key, but works with another key simopal6 Linux - General 1 07-06-2011 08:33 AM
[ASK] FTPS Server Public Key Problem arfal Linux - Server 4 03-01-2011 12:28 AM
FTPS Server public key arfal Linux - Server 2 02-24-2011 08:31 PM
Putty/SSH login failed when using RSA public key: 'Server refused our key' itsecx@gmail.com Linux - Server 10 10-04-2010 01:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:04 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