I want to share a Colab file using scp I created a RSA keypair using SSH-keygen. When I run:
!scp "/full/path/to/file" [user]@[host]:~/path/to/dest
I get (without password prompt):
>>>Host key verification failed.
>>>lost connection
Classical answers as shown here and here do not work in this context because the colab environment gives no access to the relevant files:
!ssh-keygen -R [host]
>>>do_known_hosts: hostkeys_foreach failed: No such file or directory
!rm /home/USERNAME/.ssh/known_hosts
>>>rm: cannot remove '/home/USERNAME/.ssh/known_hosts': No such file or directory
!scp "/full/path/to/file" -o 'StrictHostKeyChecking no' [user]@[host]:~/path/to/dest
same
paramiko pip module:noodles forever, no result whatsoever
you need first to make an ssh connection to your colab account by a terminal that could connect by ngrok which code is in the following
import random, string, urllib.request, json, getpass
#Generate root password
password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))
#Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
#Setup sshd
! apt-get install -qq -o=Dpkg::Use-Pty=0 openssh-server pwgen > /dev/null
#Set root password
! echo root:$password | chpasswd
! mkdir -p /var/run/sshd
! echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
! echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
! echo "LD_LIBRARY_PATH=/usr/lib64-nvidia" >> /root/.bashrc
! echo "export LD_LIBRARY_PATH" >> /root/.bashrc
#Run sshd
get_ipython().system_raw('/usr/sbin/sshd -D &')
#Ask token
print("Copy authtoken from https://dashboard.ngrok.com/auth")
authtoken = getpass.getpass()
#Create tunnel
get_ipython().system_raw('./ngrok authtoken $authtoken && ./ngrok tcp 22 &')
#Get public address and print connect command
with urllib.request.urlopen('http://localhost:4040/api/tunnels') as response:
data = json.loads(response.read().decode())
(host, port) = data['tunnels'][0]['public_url'][6:].split(':')
print(f'SSH command: ssh -p{port} root@{host}')
#Print root password
print(f'Root password: {password}')
after connecting to colab by The terminal you are allowed to use SCP on that
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With