Categories
General

Connect to your Forge server using SSH or SFTP

Create SSH Key for Github

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa (regular unix system)
$ ssh-add -K ~/.ssh/id_rsa (for macbook)

$ pbcopy < ~/.ssh/id_rsa.pub (for macbook)

Paste key into github

$ git remote add origin [email protected]:xxxxxx/xxxxxxx.git  
$ git remote -v 
$ git push -u origin master

Feb, 7 2019—#forge

Using Laravel Forge you can easily configure push-to-deploy to your sites, you can also manually deploy from the dashboard. However, sometimes you wish to access your sites’ files directly using SSH or SFTP.

To be able to do that you’ll need to add your machine’s public key to the server, this step allows the SSH service on your server to identify connections from your computer and grant access.

Depending on your Operating System, you can find guides on how to generate an SSH key in this link.

Adding an SSH Key

To add an SSH key to your server, head to the SSH Keys section of the server settings screen:

Adding an SSH Key

Once the key is added, you can SSH into your instance using the following command:

ssh [email protected]_address_here

To use SFTP, you need to download an SFTP client like FileZilla or Cyberduck. Once you run the client, provide the credentials as follow:

  • Protocol: SFTP
  • Address/Server: your_ip_address
  • Port: 22
  • Username: forge
  • Password: Leave this blank.
  • SSH Private Key: Location to the private key on your machine.

Once you press connect, the client will communicate with the server and acquire access to all the files and directories.

By Mohamed Said

Full-stack developer at Laravel. You can find me on Twitter and Github.

Leave a Reply