LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-15-2016, 11:39 AM   #1
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Rep: Reputation: 0
Question related to ssh


I am not sure if this is the correct forum for a Centos6.7/Centos 7 question but I'll ask:

I have my Centos6.7 client physically connected(hard-wired) to my Centos 7 server. I did a ssh-keygen on the client cpu and made sure my Centos 7 server was setup to receive the file from the client.(or maybe it isn't but let me give you the error) i then ran the following command:

ssh-copy-id -p35982 cajunchief@172.34.0.15 and got the following error msg:
"Bad port 'exec sh -c 'umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys && (test -x /sbin/restorecon && /sbin/restorecon ~/.ssh ~/.ssh/authorized_keys >/dev/null 2>&1 || true)''
[cajunchief@cajunchiefcom .ssh]$"

Hostname is ok, date command works, ssh-copy-id didnt?

I sure could use some help, thank you.

cajunchief
 
Old 06-15-2016, 01:40 PM   #2
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

Please, execute the command below

ls -al ~/.ssh

Look at the results on my box.

$ ls -al ~/.ssh
drwx------. 2 user group 4096 Jun 13 20:14 .
drwx--x---+ 58 user group 4096 Jun 15 16:02 ..
-rw-------. 1 user group 713 Jun 13 20:14 config
-rw-------. 1 user group 668 Aug 29 2015 id_dsa
-rw-r--r--. 1 user group 624 Aug 29 2015 id_dsa.pub
-rw-------. 1 user group 3243 Feb 12 19:55 id_rsa
-rw-r--r--. 1 user group 760 Feb 12 19:55 id_rsa.pub
-rw-r--r--. 1 user group 3581 Jun 13 20:14 known_hosts

Then give a second glance to what I have put in bold in the output above.

SSH is very careful regarding file ownership and permissions and just refuse to execute if it feels unsafe.
I am not sure it is the solution to your problem, but it least check it.
 
1 members found this post helpful.
Old 06-15-2016, 02:28 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Since you are using a non standard port you need to use quotes i.e.

ssh-copy-id "-p 35982 cajunchief@172.34.0.15"
 
Old 06-15-2016, 04:52 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
All ssh-copy-id is is a script that pastes the contents of ~/.ssh/id*.pub into ~/.ssh/authorized_keys on the remote machine. It's trivially easy to do this by hand if necessary.
 
Old 06-15-2016, 07:01 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Quote:
Originally Posted by tshikose View Post
SSH is very careful regarding file ownership and permissions and just refuse to execute if it feels unsafe.
I am not sure it is the solution to your problem, but it least check it.
Definitely, file-permissions ought to be among the first things that you verify. If the permissions on, say, the .ssh directory and its various contents are not "exactly correct," ssh will ignore them.
 
Old 06-15-2016, 07:19 PM   #6
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Since you are using a non standard port you need to use quotes i.e.

ssh-copy-id "-p 35982 cajunchief@172.34.0.15"
michaelk,
I thought you might be correct so I tried it and got this: ssh-copy-id"-p 35982 cajunchief@172.34.0.15"
bash: ssh-copy-id-p 35982 cajunchief@172.34.0.15 command not found

cajunchief
 
Old 06-15-2016, 07:20 PM   #7
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sundialsvcs View Post
Definitely, file-permissions ought to be among the first things that you verify. If the permissions on, say, the .ssh directory and its various contents are not "exactly correct," ssh will ignore them.

sundialsvcs, thanks a friend of mine told me the same thing! I am checking it.


cajunchief
 
Old 06-15-2016, 07:25 PM   #8
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by tshikose View Post
Hi,

Please, execute the command below

ls -al ~/.ssh

Look at the results on my box.

$ ls -al ~/.ssh
drwx------. 2 user group 4096 Jun 13 20:14 .
drwx--x---+ 58 user group 4096 Jun 15 16:02 ..
-rw-------. 1 user group 713 Jun 13 20:14 config
-rw-------. 1 user group 668 Aug 29 2015 id_dsa
-rw-r--r--. 1 user group 624 Aug 29 2015 id_dsa.pub
-rw-------. 1 user group 3243 Feb 12 19:55 id_rsa
-rw-r--r--. 1 user group 760 Feb 12 19:55 id_rsa.pub
-rw-r--r--. 1 user group 3581 Jun 13 20:14 known_hosts

Then give a second glance to what I have put in bold in the output above.

SSH is very careful regarding file ownership and permissions and just refuse to execute if it feels unsafe.
I am not sure it is the solution to your problem, but it least check it.
tshikose,

I looked at your files and mine looks okay too or so I think. but here is what the output is:

ls -al ~/.ssh
total 24
drwx------. 3 cajunchief cajunchief 4096 Jan 18 16:05 .
drwx------. 43 cajunchief cajunchief 4096 Jun 15 14:41 ..
drwxrwxr-x. 2 cajunchief cajunchief 4096 Jan 18 16:08 cajunchieflgt
-rw-------. 1 cajunchief cajunchief 3311 Jun 10 12:21 id_rsa
-rw-r--r--. 1 cajunchief cajunchief 746 Jun 10 12:21 id_rsa.pub
-rw-r--r--. 1 cajunchief cajunchief 1587 Apr 30 17:35 known_hosts

cajunchief
 
Old 06-15-2016, 07:25 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Quote:
ssh-copy-id "-p 35982 cajunchief@172.34.0.15"
Make sure there is a space between ssh-copy-id and "-p 35982 cajunchief@172.34.0.15". That is a bash error - command not found versus an ssh error.
 
Old 06-15-2016, 07:32 PM   #10
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by tshikose View Post
Hi,

Please, execute the command below

ls -al ~/.ssh

Look at the results on my box.

$ ls -al ~/.ssh
drwx------. 2 user group 4096 Jun 13 20:14 .
drwx--x---+ 58 user group 4096 Jun 15 16:02 ..
-rw-------. 1 user group 713 Jun 13 20:14 config
-rw-------. 1 user group 668 Aug 29 2015 id_dsa
-rw-r--r--. 1 user group 624 Aug 29 2015 id_dsa.pub
-rw-------. 1 user group 3243 Feb 12 19:55 id_rsa
-rw-r--r--. 1 user group 760 Feb 12 19:55 id_rsa.pub
-rw-r--r--. 1 user group 3581 Jun 13 20:14 known_hosts

Then give a second glance to what I have put in bold in the output above.

SSH is very careful regarding file ownership and permissions and just refuse to execute if it feels unsafe.
I am not sure it is the solution to your problem, but it least check it.
tshikose,

Anata wa nihonjin desu ka?

Thank you for your suggestion I ran the same command and this is what I got:

ls -al ~/.ssh
total 24
drwx------. 3 cajunchief cajunchief 4096 Jan 18 16:05 .
drwx------. 43 cajunchief cajunchief 4096 Jun 15 14:41 ..
drwxrwxr-x. 2 cajunchief cajunchief 4096 Jan 18 16:08 cajunchieflgt
-rw-------. 1 cajunchief cajunchief 3311 Jun 10 12:21 id_rsa
-rw-r--r--. 1 cajunchief cajunchief 746 Jun 10 12:21 id_rsa.pub
-rw-r--r--. 1 cajunchief cajunchief 1587 Apr 30 17:35 known_hosts


cajunchief
 
Old 06-15-2016, 09:24 PM   #11
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Make sure there is a space between ssh-copy-id and "-p 35982 cajunchief@172.34.0.15". That is a bash error - command not found versus an ssh error.
michaelk, sorry didn't know about the bash error but I ran it again and got this:

ssh-copy-id" -p 35982 cajunchief@172.34.0.15"
bash: ssh-copy-id -p 35982 cajunchief@172.34.0.15: command not found


cajunchief
 
Old 06-15-2016, 09:33 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
You still did not add a space between the command and the command line argument. bash still thinks it is a single command. copy-ssh-id" -p.. is not the same thing as copy-ssh-id "-p...

ssh-copy-id<space>"-p 35982 cajunchief@172.34.0.15"

Last edited by michaelk; 06-15-2016 at 09:57 PM.
 
Old 06-16-2016, 09:02 AM   #13
cajunchief
Member
 
Registered: Sep 2010
Posts: 233

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
You still did not add a space between the command and the command line argument. bash still thinks it is a single command. copy-ssh-id" -p.. is not the same thing as copy-ssh-id "-p...

ssh-copy-id<space>"-p 35982 cajunchief@172.34.0.15"
michealk, are you saying i need a space between the last character 'd' and the -p?

michaelk, YEP YOU WERE AND IT WORKED! THANKS MATE!!! Problem solved!

cajunchief

Last edited by cajunchief; 06-16-2016 at 09:05 AM.
 
  


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 related dsinha Linux - Newbie 2 06-23-2015 08:52 AM
ssh agent related query amitk.gupta09 Linux - Server 6 09-21-2011 05:30 AM
Question related to SSH rajeshkerala Linux - Newbie 12 08-17-2009 10:47 PM
An SSH - related Question.... rajeshkerala Linux - Newbie 3 12-20-2008 11:42 PM
Just a quick SSH related question... Geneset Linux - Networking 4 02-04-2008 11:07 AM

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

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