LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-14-2023, 12:56 PM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
How to get my ssh key uploaded?


SOLVED: somehow there are 2 ips. When I used the other ip, and port 22, I could upload the ssh key, login as root, and the rest I will do tomorrow!

I just bought a new VPS with Ubuntu 22.04 Server

I made an ssh key:

Quote:
pedro@pedro-HP:~$ ssh-keygen -t ed25519 -f ~/.ssh/lamian_ed25519 -C "lamian ssh key"
Generating public/private ed25519 key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/pedro/.ssh/lamian_ed25519
Your public key has been saved in /home/pedro/.ssh/lamian_ed25519.pub
The key fingerprint is:
SHA256:sY25V2jyJFXuNQ4DJ3HSF+FCwGuRCsiXV9HwIRuZl90 lamian ssh key
The key's randomart image is:
(a picture)
pedro@pedro-HP:~$
I want to upload an ssh key, so I tried this:

Quote:
pedro@pedro-HP:~$ ssh-copy-id -p 22 -i ~/.ssh/lamian_ed25519 root@123.456.789.123
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/pedro/.ssh/lamian_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: ERROR: ssh: connect to host 123.456.789.123 port 22: Connection refused
My last VPS was also Ubuntu 22.04 Server. It used port 22000, so I tried this:

Quote:
pedro@pedro-HP:~$ ssh-copy-id -p 22000 -i ~/.ssh/lamian_ed25519 root@123.456.7890.123
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/pedro/.ssh/lamian_ed25519.pub"
Nothing happened for a while, so I pressed ctrl c, then I got this:

Quote:
^C/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: 183: cannot create /home/pedro/.ssh/ssh-copy-id.9yH3JEhdj7/popids_tmp_id: Directory nonexistent
/usr/bin/ssh-copy-id: 189: cannot create /home/pedro/.ssh/ssh-copy-id.9yH3JEhdj7/popids_output: Directory nonexistent
grep: /home/pedro/.ssh/ssh-copy-id.9yH3JEhdj7/popids_output: No such file or directory
/usr/bin/ssh-copy-id: 202: cannot open /home/pedro/.ssh/ssh-copy-id.9yH3JEhdj7/popids_output: No such file
cat: /home/pedro/.ssh/ssh-copy-id.9yH3JEhdj7/popids_tmp_id: No such file or directory

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
(if you think this is a mistake, you may want to use -f option)
Any tips please on how to proceed??

What port should I use?

Last edited by Pedroski; 10-14-2023 at 01:20 PM.
 
Old 10-15-2023, 06:22 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,359
Blog Entries: 3

Rep: Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767
You'll need to know which port the server is using for SSH. Via the console provided by your hosting service:

Code:
/usr/bin/ssh -T | sort | less
Look for Port and ListenAddress
 
Old 10-16-2023, 12:35 PM   #3
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Thanks.

I was not sure which port I needed. My last little cloud server used port 22000 for ssh

I called IONOS. The guy on the telephone told me he was not sure but he thinks port 22. I tried it it worked!

I connected to the cloud server and entered:

/usr/bin/ssh -T | sort | less

but I could not see anything, just END at the bottom and a list of ssh arguments

Doesn't matter.

I was using the wrong IP, after I used the Public IP, I could connect, upload the ssh key and the connection works!

Like someone said here on one of my LQ questions before: Why do they set the owner and group of files and folders in www to root?

That caused problems for me!
 
  


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
LXer: What is SSH Key? How To Generate SSH Key in Linux? LXer Syndicated Linux News 0 04-30-2017 07:42 AM
SSH skips public key authentication for a key, but works with another key simopal6 Linux - General 1 07-06-2011 08:33 AM
VSFTP - uploaded files get scrambled indoorman Linux - Networking 2 03-12-2007 11:33 AM
Uploaded files via web interface get a 600 permissions - how can I change this? muskiediver Linux - Newbie 0 07-21-2006 09:11 AM
get full path of uploaded file in php spoody_goon Programming 2 05-10-2005 07:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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