Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save swghosh/d789e7343d57295bb860146a3641893c to your computer and use it in GitHub Desktop.
Save swghosh/d789e7343d57295bb860146a3641893c to your computer and use it in GitHub Desktop.
Start VNCServer on Mac1 EC2 Instance
# YouTube (english) : https://www.youtube.com/watch?v=FtU2_bBfSgM
# YouTube (french) : https://www.youtube.com/watch?v=VjnaVBnERDU
#
# On your laptop, connect to the Mac instance with SSH (similar to Linux instances)
#
ssh -i <your private key.pem> ec2-user@<your public ip address>
#
# On the Mac
#
# Set a password for ec2-user
sudo passwd ec2-user
# Enable VNC Server (thanks arnib@amazon.com for the feedback and tests)
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-activate -configure -access -on \
-configure -allowAccessFor -specifiedUsers \
-configure -users ec2-user \
-configure -restart -agent -privs -all
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-configure -access -on -privs -all -users ec2-user
exit
#
# On your laptop
# Create a SSH tunnel to VNC and connect from a vnc client using user ec2-user and the password you defined.
#
ssh -L 5900:localhost:5900 -C -N -i <your private key.pem> ec2-user@<your public ip address>
# open another terminal
open vnc://localhost
#
# On the mac EC2 instance, resize the APFS container to match EBS volume size
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-mac-instances.html#mac-instance-increase-volume
#
PDISK=$(diskutil list physical external | head -n1 | cut -d" " -f1)
APFSCONT=$(diskutil list physical external | grep "Apple_APFS" | tr -s " " | cut -d" " -f8)
sudo diskutil repairDisk $PDISK
# Accept the prompt with "y", then paste this command
sudo diskutil apfs resizeContainer $APFSCONT 0
#
# (optional) On the mac EC2 Instance, set screen resolution
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-mac-instances.html#mac-screen-resolution
#
brew tap jakehilborn/jakehilborn && brew install displayplacer
displayplacer list
displayplacer "id:<screenID> res:<width>x<height> origin:(0,0) degree:0"
RES="2560x1600"
displayplacer "id:69784AF1-CD7D-B79B-E5D4-60D937407F68 res:${RES} scaling:off origin:(0,0) degree:0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment