Skip to content

Instantly share code, notes, and snippets.

@githubutilities
Last active February 28, 2024 11:20
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save githubutilities/0c36d325066371e30b95 to your computer and use it in GitHub Desktop.
Save githubutilities/0c36d325066371e30b95 to your computer and use it in GitHub Desktop.
SSH into iPhone using private key

SSH into iPhone using private key

1. in Client shell

# Generate rsa key
ssh-keygen -b 2048
#or using
ssh-keygen -t rsa

# Copy public key to iPhone
scp ~/.ssh/id_rsa.pub root@iphone:~/.ssh/id_rsa.pub

2. in iPhone shell

# Add client public key to authorized_keys
cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys

3. in Client shell

# Test it out
ssh -i ~/.ssh/id_rsa root@iphone
# Then try it without `-i` option
ssh root@iphone

Troubleshooting

  • If ssh agent failed, try to delete cached ssh key using ssh-add -D.
directory or file permission
/home 755
~/.ssh/* 600
~/.ssh 700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment