These instructions are made to allow you to connect your remote device through ssh without password. Tested on macOS and Ubuntu.
Disclaimer: despite this method is well-known and quite secure, you should not use this from untrusted devices. I'm not responsible if something goes wrong with this.
$USER is the remote user and $HOST the remote host (e.g.: ssh $USER@$HOST where $USER=root and $HOST=iPhone will connect to the remote host iPhone with the user root.
ssh-keygen -t rsa # generate a pair of public/private keys encrypted with RSA
ssh $USER@$HOST "mkdir .ssh" # creates a .ssh folder at the user directory of the remote machine
cat .ssh/id_rsa.pub | ssh $USER@$HOST 'cat >> .ssh/authorized_keys' # adds your public key in the authorized keys of the remote machineNote: remember the passphrase you set during the first command!
With the previous step, trying to connect to your remote host will ask you your passphrase instead of the remote machine's password. To avoid this and remove any prompted password, type:
eval $(ssh-agent) # check if ssh agent is running
ssh-add .ssh/id_rsa # add your private key to the agent (some keys are 'id_rsa_key' instead of just simply 'id_rsa', adapt it to your configuration)
ssh-add -l # optional, list if the previous command has been successfulRun this each time you add a new device thanks to the step 1.
Under Linux distors, the eval command and the first ssh-add command have to be ran each time you login to your terminal. To avoid that, run:
sudo apt-get install keychain # install keychain to manage ssh
echo 'eval $(keychain -q --eval id_rsa)' >> ~/.bashrc # add this command at the end of your .bashrc, which is run each time you open a new terminal instanceThen relaunch your terminal.
Now you can connect your remote host securely, avoiding the need to type the password everytime, specifically when you do it often.
I personnally use it to connect to all my test iPhone when I run make install with Theos. You need to install the package OpenSSH if you want to do it too for your iPhone. The default password for it is alpine, but you can (must) change it by going to root with su, and typing passwd.
In case of problems or typos, reach me out on my Twitter.