- Local create
public_key
&private_key
- Only
private_key
can understandpublic_key
- Remote sends message encrypted based on
public_key
- Local has to use
private_key
to 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 4096
The 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_cloud
Suppose 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
~/.ssh
open fileauthorized_keys
and paste contents of yourpublic_key
to 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.com
Some 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_path
To read more some SSH
command:
man ssh