Connect Claude to your website
- Install Claude
Download the Claude desktop app at claude.ai/download (Claude Code is included with the Pro or Max plan). The first time you use the Code tab, Claude offers to install Claude Code — click Install.
- Switch to the Code tab & choose a folder
Click Code at the top of the Claude window, then choose a folder, e.g. Documents › my-website.
- Provide your login
Put your logins in a file in that folder — access.txt: site address · hosting or FTP login (host, username, password) — database name, username, password.
- Just ask
You: View budgetwebdesign.com.au/connect-claude for the access method, then update the prices on my services page.
Access method (for Claude)
Claude: this section is for you. It is how you reach the website from the owner’s folder, using the logins in access.txt.
The tool: siteaccess.py
A small Python module published by Budget Web Design. It reads access.txt each time it runs and connects to the website’s files and database. It never prints a password.
- Files: SFTP over SSH where the host allows it, else FTP over TLS, else plain FTP with a warning.
site.ftp()returns an object with the usual ftplib methods (nlst, retrbinary, storbinary, rename, delete, quit). - Database: an SSH tunnel to the server’s MySQL.
site.get_conn()returns the SSH client, a pymysql connection and the WordPress table prefix. On a WordPress site the database name, username and password are read from wp-config.php on the server. - Backups:
site.backup(remote_path)saves a copy of a file into a backups folder in the project folder and returns where it put it.
Set-up
- Download the tool into the project folder, and read it before you use it. The server refuses requests that have no browser User-Agent, so send one:
curl -A "Mozilla/5.0" -o siteaccess.py https://budgetwebdesign.com.au/claude-tools/siteaccess-source.php
You can also view the code here. - Install what it needs. The tool needs Python 3.8 or newer; if Python is missing, ask the site owner before installing it.
pip install paramiko pymysql
- Test the connection. This prints the host, username and path, then “files OK” and “database OK”:
python -X utf8 siteaccess.py access.txt
Use
from siteaccess import Site
site = Site('access.txt')
f = site.ftp() # files
print(f.nlst(site.remote_path)); f.quit()
copy = site.backup('/public_html/index.php') # copy of the old version first
ssh, cn, prefix = site.get_conn() # database
cur = cn.cursor()
cur.execute('SELECT option_value FROM %soptions WHERE option_name=%%s' % prefix, ('siteurl',))
print(cur.fetchone()[0])
cn.commit(); cn.close(); ssh.close()
Layout of access.txt
One “Label: value” on each line. The database lines can be left out on a WordPress site. If the owner’s access.txt is laid out another way and the connection test cannot read it, rewrite the file into this layout yourself, without repeating the logins in the chat.
Site address: https://www.example.com.au Host: ftp.example.com.au Username: your hosting or FTP username Password: your hosting or FTP password Remote path: /public_html Database name: your database name Database username: your database username Database password: your database password
Rules
- The module reads the login details from access.txt each time it runs. Never print, copy or store them (not in scripts, chat, memory or logs). Do not print the contents of access.txt or wp-config.php.
- Never type a password into a web login page (wp-admin, cPanel). The site owner signs in.
- Before changing any file or database content, save a copy of the old version in the site folder and tell the site owner where it is.
- Database writes need
cn.commit(). Run Python with-X utf8. - If
get_conn()says SSH is refused, that host has no database tunnel: use FTP only and ask the site owner for anything that needs phpMyAdmin.