Cursor と Replit の SSH 接続ガイド
ヒント
SSH を使用して Cursor を Replit プロジェクトに接続し、シームレスな開発体験を実現しましょう。
前提条件
始める前に、以下のものが揃っていることを確認してください:
- Cursor がインストールされていること
- Replit アカウント
- SSH クライアントがインストールされていること
- ターミナルコマンドの基本的な理解
SSH キーの設定
1. SSH キーの生成
- Windows
- macOS/Linux
# SSH キーを生成
ssh-keygen -t ed25519 -C "your@email.com"
# SSH エージェントを起動
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
# SSH キーを生成
ssh-keygen -t ed25519 -C "your@email.com"
# SSH エージェントを起動
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
2. Replit にキーを追加
-
公開キーをコピー:
# Windows
type $env:USERPROFILE\.ssh\id_ed25519.pub
# macOS/Linux
cat ~/.ssh/id_ed25519.pub -
Replit に追加:
- Replit の設定に移動
- SSH キーセクションに移動
- 公開キーを貼り付け
- 変更を保存
Cursor の設定
1. SSH 設定ファイルの作成
~/.ssh/config
を作成または編集:
~/.ssh/config
Host replit
HostName ssh.replit.com
User your-replit-username
IdentityFile ~/.ssh/id_ed25519
ForwardAgent yes
2. 接続テスト
# SSH 接続をテスト
ssh replit
Replit プロジェクトへの接続
1. プロジェクト URL の取得
# 形式: ssh.replit.com:your-username/project-name
replit-url="ssh.replit.com:username/project"
2. プロジェクトのクローン
# SSH 経由でクローン
git clone ssh://replit-url
プロジェクトの操作
1. リモート開発
# Cursor でプロジェクトを開く
cursor .
# リモート設定を構成
{
"remote.SSH.remotePlatform": "linux",
"remote.SSH.path": "/usr/bin/ssh"
}
2. 同期
# 変更をプッシュ
git add .
git commit -m "Cursor からの更新"
git push origin main
# 変更をプル
git pull origin main
トラブルシューティング
一般的な問題
-
接続拒否
# SSH エージェントを確認
ssh-add -l
# SSH エージェントを再起動
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519 -
認証失敗
# キーの権限を確認
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub -
キーが見つからない
# SSH 設定を確認
ssh -vv replit
高度な設定
1. 複数のプロジェクト
~/.ssh/config
Host replit-project1
HostName ssh.replit.com
User username
IdentityFile ~/.ssh/id_ed25519
RemoteCommand cd /home/runner/project1
Host replit-project2
HostName ssh.replit.com
User username
IdentityFile ~/.ssh/id_ed25519
RemoteCommand cd /home/runner/project2
2. カスタムポートフォワーディング
Host replit
HostName ssh.replit.com
User username
LocalForward 3000 localhost:3000
LocalForward 8080 localhost:8080
3. パフォーマンス最適化
Host replit
HostName ssh.replit.com
User username
Compression yes
TCPKeepAlive yes
ServerAliveInterval 60
ベストプラクティス
1. セキュリティ
# SSH 設定ファイルの権限
chmod 600 ~/.ssh/config
# キーのパスフレーズを使用
ssh-keygen -t ed25519 -C "your@email.com" -N "your-passphrase"
2. 整理
~/.ssh/
├── config
├── id_ed25519
├── id_ed25519.pub
└── known_hosts
3. バックアップ
# SSH 設定のバックアップ
cp -r ~/.ssh ~/.ssh-backup
# 公開キーのエクスポート
ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/ssh-keys-backup.pub
Git との統合
1. Git 設定
# Git 設定のセットアップ
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
2. Git 無視
.gitignore
# SSH 関連ファイル
.ssh/
*.pem
*.key
3. Git フック
.git/hooks/pre-push
#!/bin/sh
# プッシュ前に SSH 接続を確認
ssh -T replit || exit 1
成功のためのヒント
-
定期的なメンテナンス
- SSH キーを定期的に更新
- 接続状態を確認
- アクセスログを監視
-
セキュリティのベストプラクティス
- 強力なパスフレーズを使用
- 定期的にキーをローテーション
- 認証済みキーを監視
-
ワークフロー最適化
- SSH 設定のエイリアスを使用
- 自動接続を設定
- エディタ統合を設定
ヒント
SSH キーと設定ファイルのバックアップを常に保持しておきましょう!