Closed lrushi closed 3 years ago
After you login as colab user, you can use sudo
to run a command that require root or su
to become root.
These command doesn't work for you?
@demotomohiro it worked but I am using remocolab to use colab in vscode. Some times the I want to run jupyter notebooks as root. loginning in vscode and using jupyter from that wont give me root access inside jupyter notebooks in colab. So I tought having root access would be better for the ones who need it.
So if there is a chance to login as root it will be helpful.
Please read this before enabling root login via ssh: https://unix.stackexchange.com/questions/82626/why-is-root-login-via-ssh-so-bad-that-everyone-advises-to-disable-it
I tested this code and it worked for me.
!mkdir /root/.ssh
with open("/root/.ssh/authorized_keys", 'w') as f:
f.write("my public key")
!chmod 700 /root/.ssh
!chmod 600 /root/.ssh/authorized_keys
If you setup public key authentication correcly, you can login to ssh without using password. Did you setup public key in your ssh client correcly, and replaced "my public key" in above code to your public key? "my public key" string need to be replaced with content of your public key file including text that doesn't look random.
I have no idea what I did wrong. The regular login as user "colab" is working just fine both password and ssh keys. But as soon as I try to login in as root it is giving me the error which I pasted above.
These are the things that I ran in order in jupyter notebook
I generated the SSH keys using the command ssh-keygen -t ecdsa -b 521
as you mentioned.
I stored my public key as a variable pubkey
i.e pubkey = "content in the ecdsa.pub"
and passed pubkey
as argument to
remocolab.setupSSHD()
. This variable is my first cell.
After that I ran the following commands as u mentioned in the readme that is
!pip install git+https://github.com/demotomohiro/remocolab.git
import remocolab
remocolab.setupSSHD(public_key = pubkey, ngrok_region = "in", mount_gdrive_to = "drive")
This is my second cell.
After that cell I ran the following commands
!mkdir /root/.ssh
with open("/root/.ssh/authorized_keys", 'w') as f:
f.write("my public key")
!chmod 700 /root/.ssh
!chmod 600 /root/.ssh/authorized_keys
This is my third cell.
I logged into ssh using this as colab and it worked fine with both ssh keys and password
ssh -o UserKnownHostsFile=/dev/null -o VisualHostKey=yes -p 10112 colab@0.tcp.in.ngrok.io
I removed colab from top command and replaced it with root and tried to ssh as root but failed
ssh -o UserKnownHostsFile=/dev/null -o VisualHostKey=yes -p 10112 root@0.tcp.in.ngrok.io
It gave me the error as typed above in the previous comment. If I did any thing wrong tell me else I will just use ssh as user colab and I personally dont think I made any mistake.
/root/.ssh/authorized_keys
contains your public key?
Did you edit sshd_conf?
I think you should report the issue to vscode so that you can do what you want to do without root login via ssh rather than trying to root login via ssh. Because this. There are people want to forbid root login via ssh. If vscode requires root login via ssh, they would never use it.
I will use user colab and not root from now as u mentioned but its not just vscode even in terminal I have the same issue when I try to login as root. I don't think it is about vscode. May be its the region issue? idk. Any way thanks for your help.
I am unable to login as root. Normal user colab is working just fine but root user is not working by both using ssh keys and password.
I exactly followed the guide in readme.md and still unable to connect. This is what i ran in colab as mentioned after the ssh server creation.
I used the root password as the input to the shell prompt. I even tried regular colab user password but it didnt work. Even ssh keys also didnt work. The following below is the output when i tried to connect with password.
If I made any mistake please tell me what to do to get root access else if not It may be a bug so please look into it as normal colab user is working just fine.