PentOpsVault @syztem4our666

PentOpsVault
Linux

SSH

Linux

SSH Service

Start SSH service

(sudo) service ssh start

Check SSH service status

(sudo) service ssh status

Stop SSH service

(sudo) service ssh stop

Restart SSH service

(sudo) service ssh restart

Open config file (usual location)

sudo nano /etc/ssh/sshd_config

SSH Keys

Generate a new SSH key

ssh-keygen -t rsa -b 4096

Send the key to the server

ssh-copy-id user@server

Convert id_rsa into PPK

puttygen current_key -o keyname.ppk

SSH Connections

Connect to a server (default port 22)

ssh user@server

Use a specific port declared in sshd_config

ssh user@server -p other_port

Run a script on a remote server

ssh user@server script_to_run

Compress and download from a remote server

ssh user@server "tar cvzf - ~/source" > output.tgz

Specify another SSH key for connection

ssh -i ~/.ssh/specific_ssh_fkey

SCP (Secure Copy)

Copy a file from a remote server to a local machine

scp user@server:/directory/file.ext local_destination/

Copy a file between two servers

scp user@server:/dir/file.ext user@server:/dir

Copy a file from a local machine to a remote server

scp local_destination/file.ext user@server:/directory

Use a specific port declared for SSH in sshd_config

scp -P port

Copy recursively a whole folder

scp -r user@server:/directory local_destination/

Copy all files from a folder

scp user@server:/directory/* local_destination/

Copy all files from a server folder to the current folder

scp user@server:/directory/* .

Compress data on network using gzip

scp -C
scp -v

On this page

Edit on GitHub