LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-11-2018, 07:35 AM   #1
krazybob
Member
 
Registered: Oct 2009
Location: Los Angeles, CA
Distribution: Centos 5.x
Posts: 133

Rep: Reputation: 3
Unable to change immutable attributes


Somehow the attributes of .ssh were changed and I am unable to change them back. I need 700 permissions and it only allows 000.

Code:
[root@clss06 /]# chattr -i /root/.ssh
[root@clss06 /]# lsattr -a /root/.ssh
-------------e- /root/.ssh/authorized_keys
-------------e- /root/.ssh/known_hosts
-------------e- /root/.ssh/..
-----a-------e- /root/.ssh/.
I never changed this to begin with. It is a hosting server under Virtuozzo. Even logging in as root from the hardware node of Virtuozzo refuses to allow me to chnage to attr's.

Any thoughts?

Thank you in advance.
 
Old 02-12-2018, 08:59 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You're using the wrong commands for viewing and setting "permissions" (a/k/a "mode") on a file/directory:

ls -ld /root/.ssh

Should show something like:
drwx------. 3 root root 4096 Jan 16 16:27 /root/.ssh

d = directory
r = (4) read access (for owner)
w = (2)write access (for owner)
x = (1) execute access (for owner - for a directory x is required for directory access).
--- = (0) No permissions for group
--- = (0) No permissions for other

Adding 4 + 2 + 1 = 7.

To change the directory to 700:
chmod 700 /root/.ssh

Last edited by MensaWater; 02-12-2018 at 09:01 AM.
 
Old 02-12-2018, 11:01 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
~/.ssh = 700 and
~/.ssh/{authorized_keys,known_hosts} = 600


Code:
ls -ld ~/.ssh && ls -lF $_
drwx------ 2 root root 4096 Jan 15 09:45 .ssh
total 16
-rw------- 1 root root 1192 Jan 15 09:45 authorized_keys
-rw------- 1 root root 1347 Jan 15 09:44 authorized_keys.bak
-rw------- 1 root root 1679 May 24  2017 db
-rw-r--r-- 1 root root 1426 May 24  2017 known_hosts
ls -ld is List Directory
ls -lF is List Files only

Generic References
https://help.ubuntu.com/community/SSH/OpenSSH/Keys
https://wiki.archlinux.org/index.php/SSH_keys
Both excellent, esp #2. Ask if you are unsure.
The ssh-keygen command below side-steps most of the interactive questions asked by ssh-keygen if you ran it w\out the options.
Don't freak out or panic.


Make strong keys quickly No password.. (or it may prompt you to use one on the created ssh key you are making), been awhile.
Code:
ssh-keygen -f /path/to/file_rsa -t rsa -N '' -b 4096 -q
I believe I mis-spoke, if you hit the "-q" you should prompted for password.
Definately, maybe!

Last edited by Habitual; 02-12-2018 at 11:04 AM.
 
Old 02-12-2018, 04:02 PM   #4
krazybob
Member
 
Registered: Oct 2009
Location: Los Angeles, CA
Distribution: Centos 5.x
Posts: 133

Original Poster
Rep: Reputation: 3
I was actually using the exact commands provided by Plesk. Hmm... I know how to create keys but since the directory was not writable any attempt would fail. Persons Unknown and by unknown means entered the server that I am trying to my great customers off of and change permissions on the directory. I don't know why. I know I didn't change the permissions. I had no reason to change the permissions. But I use the exact commands plesk provided to me. Isn't it amazing how many different ways there are to accomplish the same thing?

Code:
  972  lsattr -a /root/.ssh 
  973  ls -la /root/.ssh/
  974  chmod 700 /root/.ssh
  975  ls -la /root/.ssh/
  976  chattr -a /root/.ssh
  977  ls -la /root/.ssh/
  978  lsattr -a /root/.ssh 
  979  chmod 700 /root/.ssh
  980  chmod 600 /root/.ssh/authorized_keys
  981  chmod 644 /root/.ssh/known_hosts
  982  history
  983  hostname
  984  cd /root
  985  ls -lah
  986  chattr -i .ssh
  987  chmod 700 .ssh
  988  lsattr .ssh
  989  cd ..
  990  lsattr .ssh
  991  lsattr /root/.ssh
  992  pwd
  993  chattr -i /root/.ssh
  994  lsattr /root/.ssh
  995  lsattr -a /root/.ssh
  996  chattr -i /root/.ssh
  997  lsattr -a /root/.ssh
It seems that the +a attribute was also set and not allowing me to set the permissions to 700 or anything else for that matter. Plesk resolved the issue but I'm going to remember your ways as well. There's more than one ways to skin a cat as they say. What I do when I get helpful information like you provided as I copy it in Notepad and I have built up quite a knowledge base for myself. That way when someone down the road has a similar problem I may be able to provide them with the answers just as you folks have tried to help me. I wonder what the difference between the commands is though?
 
  


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
is e2fsck change the file system attributes.? mpasha06 Linux - General 2 05-11-2017 12:49 AM
[SOLVED] Can't change attributes on /etc/updatedb.conf ghamilton Linux - Newbie 5 02-29-2016 10:01 AM
Unable to remove immutable flag for SSHD_CONFIG pcslinux123 Linux - Security 16 03-25-2014 05:31 PM
I am unable to set immutable flag in SuSE udayakumarsv SUSE / openSUSE 1 03-30-2009 11:34 PM
How to check/change file attributes under dosemu? ganoo Linux - Software 0 06-09-2005 04:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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