srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ssh.md
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2023-06-04 15:52:11 +0200
committersrdusr <[email protected]>2023-06-04 15:52:11 +0200
commit5dea3b7895ebb12f22695304f60a332a72e2054b (patch)
tree60aaf5dffc54a8a04ba0743bcd7c27e082693a67 /tools/ssh.md
parent412092dbaa37aa04fea553986b1ef58a2d1f42c0 (diff)
downloadnotes-5dea3b7895ebb12f22695304f60a332a72e2054b.tar.gz
notes-5dea3b7895ebb12f22695304f60a332a72e2054b.zip
Making connecting using ssh info more concise
Diffstat (limited to 'tools/ssh.md')
-rw-r--r--tools/ssh.md42
1 files changed, 28 insertions, 14 deletions
diff --git a/tools/ssh.md b/tools/ssh.md
index b005a08..0073ef0 100644
--- a/tools/ssh.md
+++ b/tools/ssh.md
@@ -124,23 +124,37 @@ How to SSH File Transfer from Remote to Local
- (Optional) Install openssh
`$ apt install openssh`
-- Make sure `passwd` is set for the server (root/non-root user)
-
+- Make sure `passwd` is set for the remote/local machine (root/non-root user)
+`# passwd` # For root
+or
+`$ passwd <username>` # For user
+
+- Confirm that machines are connected to the internet/LAN or via cables if possible
+- Get the IP address (recommended to get both remote and local)
+`# ip a`
+or
+`# ifconfig`
+> NOTE: Getting the correct IP address will vary in method and might require trial and error.
+A few factors to consider are whether either remote/local are in a VM and what OS is being used, example Windows would use `# ipconfig`.
+- If the remote machine is root then confirm that `PermitRootLogin yes` is set in /etc/ssh/sshd_config on the remote machine. If it's not, set it
+`# vim /etc/ssh/sshd_config`
+> NOTE: - Optional find and change the default line `#Port 22` to desired port, example: `Port 8022`
+- Reload the sshd daemon on the remote machine
+`# pkill sshd && /usr/bin/sshd`
+- Generate keys
+`# ssh-keygen A`
+`# ssh-keygen`
+ or
+ `$ ssh-keygen -b 4096 -t rsa`
+> NOTE: No need to enter passphrase unless desired.
+- OpenSSH has a utility to send the key remotely to either machine, only use the `-p` flag if specifying a `<port>` to use
+`$ ssh-copy-id -p <port> -i ~/.ssh/id_rsa.pub [email protected]`
+> NOTE: Working out which `<port>` to use (default is usually 22) might also require trial and error dependent on remote/local configurations. Some commands to check current active ports: `lsof -Pi | grep ssh` and `netstat -lntu`.
+- Connect to the target machine on the local machine via ssh
+`# ssh -p <port> [email protected]`
- On server machine edit sshd_config
`$ vi /etc/ssh/sshd_config`
-- Find and change the line `#Port 22` to `Port 8022`
-- Find the line `#PermitRootLogin prohibit-password` or `#PermitRootLogin yes` and change it to `PermitRootLogin yes`. If it is already `PermitRootLogin yes` then don't change anything.
-- Now do `ssh-keygen -A` and then `ssh-keygen`
- or
- `$ ssh-keygen -b 4096 -t rsa`
-
-- OpenSSH has a utility to send the key remotely via either machine
-`$ ssh-copy-id -p 8022 -i ~/.ssh/id_rsa.pub [email protected]`
-
-- Ssh into the host server machine from the local machine
-`$ ssh [email protected] -p 8022`
-
- - -