Skip to content

Instantly share code, notes, and snippets.

@DomiR
Last active October 22, 2021 00:05
Show Gist options
  • Save DomiR/8870918 to your computer and use it in GitHub Desktop.
Save DomiR/8870918 to your computer and use it in GitHub Desktop.
Iphone passwordless ssh

Passwordless SSH

If you have no own key in ~/.ssh/ calld id_rsa.pub then create one:

ssh-keygen -t rsa

Copy the public file to the iphone

scp id_rsa.pub root@IPHONIP

Login to iphone

ssh root@IPHONEIP

Copy key to authorized_keys

mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
chmod 644 .ssh/authorized_keys
chmod 700 .ssh

Edit /etc/ssh/sshd_config

nano /etc/ssh/sshd_config

// - uncomment this - // 
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

// -       to       - // 
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

Restart sshd

launchctl stop com.openssh.sshd
launchctl start com.openssh.sshd

Everthing in one run

APPLEIP="<IP>"
cat ~/.ssh/id_rsa.pub | ssh root@$APPLEIP '(
	cat > /var/root/tmp.pubkey;
	mkdir -p /var/mobile/.ssh;
	touch /var/mobile/.ssh/authorized_keys;
	cat tmp.pubkey >> /var/mobile/.ssh/authorized_key;
	chmod 644 /var/mobile/.ssh/authorized_keys;
	chmod 700 /var/mobile/.ssh;
	mkdir -p /var/root/.ssh;
	touch /var/root/.ssh/authorized_keys;
	cat tmp.pubkey >> /var/root/.ssh/authorized_keys;
	chmod 644 /var/root/.ssh/authorized_keys;
	chmod 700 /var/root/.ssh;
	rm /var/root/tmp.pubkey;
	echo "RSAAuthentication yes" >> /etc/ssh/sshd_config;
	echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config;
	echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config;
	launchctl stop com.openssh.sshd;
	launchctl start com.openssh.sshd;
	)'

Backing Up Your Packages

dpkg –get-selections> installed-apps.txt

Restore

passwd
login mobile

passwd
dpkg --install bigbosshackertools

# Set debs 
dpkg –-set-selections< installed-apps.txt
apt-get -u dselect-upgrade
@SwiftWinds
Copy link

SwiftWinds commented Jan 3, 2020

@supermamon Confirmed working on iOS 12.4. Thanks for the hasty treat! ❤️😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment