When you connect to your web hosting account via SSH, you usually land in your home directory (~).
If you prefer to start directly in your website folder (~/public_html), you can set it easily by editing your shell profile.


Step-by-step guide

1. Connect via SSH

Log in to your account:

ssh username@yourdomain.com

Your prompt will look like:

username@server [~]#

2. Edit your bash profile

Run these commands to make SSH always start in your public_html folder:

cat >> ~/.bash_profile <<'EOF'
# Go to public_html automatically on SSH login
case $- in
*i*) cd ~/public_html 2>/dev/null || true ;;
esac
EOF

This tells the system to change directory to ~/public_html only for interactive SSH logins.


3. Log out and log back in

Exit and reconnect via SSH:

exit
ssh username@yourdomain.com

You should now see:

username@server [~/public_html]#

To confirm:

pwd

Expected output:

/home/username/public_html

Why this works

The code checks if your session is interactive (*i*) before running cd ~/public_html, ensuring SCP or non-interactive SSH commands still work normally.