Tuesday, December 8, 2015

SSH Tips

~/.ssh/config

Host *
    ControlMaster auto
    ControlPath /tmp/ssh-%r@%h:%p
    ControlPersist 600
    ServerAliveInterval 60

Host myssh
    User thiago
    Hostname server.ssh.com


$ ssh  myssh
type password
open a new terminal
$ ssh myssh
no password will be required since it will use the same connection


SFTP

Sending file

$ echo "put example.txt /tmp/" | sftp myssh
$ sftp myssh <<< "put example.txt /tmp/"

Geting files from

$ echo "get /remotefolder/*  /tmp/" | sftp myssh
$ sftp myssh <<< "get /remotefolder/*  /tmp/"

Cat & ssh

Send file

$ cat example.txt | ssh myssh 'cat > /tmp/example.txt'

Receive file

$ ssh myssh 'cat /tmp/example.txt' | cat > /tmp/example.txt


ssh via balabit

$ ssh -l usario@hostdestino hostbalabit

sftp via balabit

$ sftp -o User=usuario@hostdestino hostbalabit



No comments:

Blog Archive