- Local create
public_key&private_key - Only
private_keycan understandpublic_key - Remote sends message encrypted based on
public_key - Local has to use
private_keyto understand (decrypt) remote’s message - To easy to manage SSH, you can use Terminus app
# generate rsa keyssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# without emailssh-keygen -t rsa -b 4096The default of location SSH Key:
- Windows:
C:\Users\namnh198\.ssh - Linux & MacOS:
~/.ssh => /home/namnh198/.ssh
- Create a key different names, e.g
id_rsa_magento_cloud,… - Add to
~/.ssh/config
Host magento_cloudHostname *.magento.cloud # match with all subdomain github.comIdentityFile ~/.ssh/id_rsa_magento_cloudUser <your_username>- Add to
ssh-keygen(Don’t need to retype password again)
eval "$(ssh-agent -s)"ssh-add ~/.ssh/id_rsa_magento_cloudSuppose that we wanna connect to a remote host username@remote.com from a local machine
- On local machine, copy public key at
~/.ssh - On remote server, go to
~/.sshopen fileauthorized_keysand paste contents of yourpublic_keyto it
ssh user@hostname.com
# with port != 22ssh user@hostname.com -p remote_port
# connect with specific private_keyssh -i your_private_key user@hostname.comSome arguments:
i: Identity Filef: Request ssh to go to background just before command excutionL: Local port forwardingp: Portq: Quiet modev: Verbose modeX: Running GUI remote app locallyC: Use data compression
# check versionssh -v
# disconnectexit
# copy file local -> remotescp local_file user@hostname.com:/remote_path
# download file remote -> localscp user@hostname.com:/remote_file local_pathTo read more some SSH command:
man ssh