Migrating to Linux series.
PuTTY Settings
PuTTY for Linux.
At first I didn’t get how to use it.
After I finally figured it out, my impression was: it’s basically a GUI for the config file.
- Open the app: the big middle panel is for selecting a
configprofile. You canLoad/Save/Delete. - There is
Default Settings. This is what PuTTY loads by default at startup, and it’s also the template for creating otherconfigprofiles. - To add an SSH config, fill in
Host Name/IP address,Port, etc. Then type the profile name in the blank field underSaved Sessionsand clickSave. - To edit a config later: click the profile,
Loadit (like opening the config file), make changes, thenSave(like saving it).
Configure Default Settings first. Then creating new SSH configs will be much less work.
Here are some of my basic settings:
- Window
Change window size.
The default SSH window is too small. AdjustColumnsandRowsto something reasonable. - Window ->> Selection
MakeCtrl Shift C/VuseClipboard, matching terminal behavior. - Connetction
TCP keepalives
Enable this to keep the SSH session alive.
This alone is not enough; you also need to setSending of null packets to keep sessions activeto an interval value, e.g. 4 seconds. - Connetction ->> Data
Fill inAuto-login usernameso you don’t need to type it every time. - Connetction ->> Proxy
Essential in the wall country. No further comment.
Those are my basic PuTTY settings. Fonts/colors/etc. are personal preference.
(It took some time to set up; not writing it down would be a waste.)
Public-Key Authentication
If you want real “one-click login”, set up public-key authentication. Convenient and secure, why not.
References
荒岛 - SSH那点事:公钥验证/两步验证/Fail2ban
Log in to a Linux server with an SSH private key on a Windows client
How To Use Putty with an SSH Private Key Generated by OpenSSH
I’m too noob. I couldn’t tell which machine is local vs remote from the first tutorial. I only understood after reading the second one.
Rough Idea
Generate a key pair on the local machine. Keep the private key safe. Put the public key on the remote machine, and enable public-key authentication there.
Then when you log in from the local machine, the remote machine checks your public key and goes: oh, a familiar machine, let it in.
Steps
- Generate key pair on local machine
ssh-keygen -b 4096, press Enter all the way. This generatesid_rsaandid_rsa.pub.
The first is the private key (keep it safe). The second is the public key (share it).
- Enable public-key auth on the remote machine
mkdir -p ~/.ssh && touch ~/.ssh/authorized_keyscreate the file to store keys.chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keysset permissions so others can’t read it.vim ~/.ssh/authorized_keyspaste the public key from the local machine.vim /etc/ssh/sshd_configedit sshd config:PubkeyAuthentication yesenable public-key authPasswordAuthentication no(optional) disable password login if desired
systemctl restart sshdrestart sshd
- Configure PuTTY to use the key
- Convert key via
puttygen
PuTTY can’t use the raw RSA private key file directly; it needs PuTTY’s format. Installing PuTTY also installs the converter. Command:puttygen inputfile -o ouputfile
Runputtygen ~/.ssh/id_rsa -o ~/.ssh/id_rsa_puttyto convert your local private key. - Select the private key for authentication
Connetction ->> SSH ->> Auth
SetPrivate key file for authenticationto the convertedid_rsa_putty, and save.
- Convert key via
Now you can “one-click login” to the remote host.
The end,撒花.
Updates
2020/09/16 update
The default key algorithm from ssh-keygen is RSA.
I read online that ed25519 might be more secure.
ssh-keygen -t ed25519 -b 2048 gives you an ed25519 key.
2020/09/17 update
How to Change Default SSH Port in CentOS 8
How To Change OpenSSH Port On CentOS 7
Need to allow SSH port(eg.2244) through the firewall
sudo firewall-cmd --permanent --remove-service=sshsudo firewall-cmd --permanent --add-port=2244/tcpsudo firewall-cmd --reload