Some Linux User and SSH Tips and Tricks
SSH Login With Keys
From Your Computer
Make sure you have created a private/public key pair. There are tons of articles online about how to use openSSH (for real operating systems) or some convoluted third-party app like Pagent or Putty to generate an SSH key.
Copy the contents of your id_rsa.pub file (you can use this public key on multiple services, BTW, they do not need to be unique per service.
On The Server
Login with your user account using an old-fashioned username/password.
Now let’s setup a way to login from your computer without typing passwords:
mkdir .ssh cd .ssh vim authorized_keys
press i to enter insert mode
paste in the contents of that id_rsa.pub file you copied earlier
press <esc> to exit insert mode
type :wq! to quit vim
If the permissions of the .ssh directory and files within are not correct you cannot login. chmod 777 (allow anyone to do anything) will not work as the SSH app checks for gaping security holes in file and directory permissions when authorizing access.
chmod 644 authorized_keys cd .. chmod 700 .ssh
Creating Login Directories
As root type:
Useful if a user account was created without the “create login directory” option, which I always seem to forget.
SCP Files Between Servers
You’ll need an SSH username with password (or SSH pre-shared keys) on the target (remote) system.
Remember the default public key that will be sent is the ~/.ssh/id_rsa.pub file on the current local system, so that content needs to be somewhere in the target system’s user .ssh/authorized_keys file.
From the server where the file resides.
scp <local_filename> <username>@<ip_address|domain>:<targetfile>
scp backup-akamai2.tar.gz firstname.lastname@example.org:/home/lc/akamai2.tgz
You must log in to post a comment.