I'm new to linux. I downloaded an image of ubuntu 12 for VirtualBox and I want to configure the .ssh/config file to access via ssh to an application in development.
I access /home/ubuntu folder and I login as root, I type vim .ssh/config and when I save I get the error: .ssh/config E212: Can not open file for writing.
Y saved it with :w, :w!, :wq! and I can´t.
I tried with sudo .ssh/config and sudo ~/.ssh/config.
I've tried different virtual machines so i don't know can be causing this error. I hope you can help me.
24 Answers
If the .ssh folder didn't exist you could get this.
In which case you could create it first with:
mkdir ~/.ssh
chmod 700 ~/.ssh When using vi on files with elevated permissions you have to use sudo
For example you must use sudo vi .ssh/config
This is because the .ssh directory or the .ssh/config file must be owned by root and when using the sudo command it elevates your privileges to root for the duration of that process.
1You can be probably in read mounted filesystem though you can try the following steps For some reason the file you are writing to cannot be created or overwritten. The reason could be that you do not have permission to write in the directory or the file name is not valid.
Vim has a builtin help system, I just quoted what it says to :h E212. You might want to edit the file as a superuser like sudo vim FILE. Or if you don't want to leave your existing vim session (and know have proper sudo rights), you can issue:
:w !sudo tee % > /dev/null Which will save the file. I found this on
Thanks & Regards,
Alok
Go to C:\Users\user\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\user.ssh and make sure you can't see any config file with the windows explorer, in my case there was already one config file, which i was not able to see it via ubuntu terminal