help

write in irc (#envs) or
contact sudoers@envs.net for any other help requests.

# show public ip

curl ip.envs.net

# termbin - aliases

echo 'alias tb="nc tb.envs.net 9999"' >> ~/.bash_aliases

you can POST a text:
  echo less typing now! | tb

or Content of a file:
  cat ~/some_file.txt | tb

# the null pointer - aliases

add the following lines to you're aliases file ~/.bash_aliases

0file() {} curl -F"file=@$1" https://envs.sh ; }
0url() { curl -F"url=$1" https://envs.sh ; }
0short() { curl -F"shorten=$1" https://envs.sh ; }

HTTP POST files here:
  0file "yourfile.png"

you can also POST remote URLs:
  0url "https://example.com/image.jpg"

or you can shorten URLs:
  0short "https://example.com/some/long/url"

if you want a nice wrapper, try ~tomasino's pb

# ssh

ssh details and usage

ports 22, 80, 443, 2222 and 2223 are available for ssh.
use ssh.envs.net to reach the secondary ip and use 80 and 443 for ssh.
so, for example, you can do:
  ssh user@envs.net
  ssh -p2223 user@envs.net

or for the secondary ip:
  ssh -p443 user@ssh.envs.net

if you have a slightly shaky connection then you can also use mosh.

create a ssh-key

make sure you have a ~/.ssh directory
  mkdir -m 700 ~/.ssh

create your key
  ssh-keygen -t rsa -b 4096

your public and private key will be located at
  cat ~/.ssh/id_rsa.pub

ssh config

define ssh host aliase in ~/.ssh/config

Host envs.net
  HostName envs.net
  Port 2223
  User user
  LocalForward localhost:6667 localhost:6667

now you can use a simple ssh envs.net to connect.
there are tons of other options, including this LocalForward line to automatically set up the tunnel as show below.
for more available options, see the man page: man ssh_config

ssh tunnels

for example, you want to get into znc with your local client (weechat, etc),
but your local network blocks znc ports. you can connect to envs.net, and use port forwarding to get on.

if you are connecting from a linux machine, you can do this:
  ssh -L 6667:localhost:6667 envs.net

after being logged in, open your local irc client, and use 127.0.0.1:6667
for your server setting. voila! you're now on envs.net znc server.

what that ssh command did was open a local port tunnel (-L), using local port 6667 (6667:)
pointed at localhost (from the remote's point of view), on remote port 6667 (default irc port).

putty has the same ability (for windows and mac users), under connection > ssh > tunnels.

you can do this for any arbitrary port.

import & authorize a public ssh-key

from URL (on remote machine)
  echo $(curl -sL https://example.com/id_rsa.pub) | tee -a ~/.ssh/authorized_keys

over ssh (on local machine)
  ssh-copy-id -i ~/.ssh/id_rsa.pub -p2223 user@envs.net;

ssh remote execution

ssh envs.net ping google.de

or
  ssh envs.net bash -c "'uname -a'"

exec a local script
  ssh envs.net 'bash -s' < local_script.sh

# scp usage

copy ssh pub key to remote:
  scp -P 2223 ~/.ssh/authorized_keys user@envs.net:~/.ssh/authorized_keys

copy website index.html from remote:
  scp -P 2223 user@envs.net:~/public_www/index.html ~/public_www/

# rsync usage

sync website to remote:
  rsync -avz -e "ssh -p 2223" ~/public_www user@envs.net:~
sync website from remote:
  rsync -avz -e "ssh -p 2223" user@envs.net:~/public_www ~/

# sftp usage

connect: sftp -oPort=2223 user@envs.net

commands:

exit: exit
print help: help

transferring

files to remote:
  put localfile remotefile

dir to remote:
  put -r localdir remotedir

files from remote:
  get remotefile localfile

dir from remote:
  get -r remotedir localdir

example:

add index.html to public_www Dir:
  put public_www/index.html public_www

add ~/.ssh/authorized_keys:
  put .ssh/authorized_keys .ssh/authorized_keys

single line usage (on local machine)

  to remote: sftp -P 2223 user@envs.net:remotedir <<< $'put localfile_path'
  from remote: sftp -P 2223 user@envs.net:remotefile localfile

# cron/crontab

with cron you can run specific tasks at a specific time.

display current crontabs:
  crontab -l

add/edit crontabs:
  crontab -e

example: - backup your mysql db once per day

..
# m h   dom mon dow command
0   0   *   *   *   /usr/local/bin/envs_mysql.sh backup

for more information see the manual pages of crontab(5) and cron(8)

# daemonize processes

so you've got a process that you want to keep running. you might have it in a
tmux or screen session. let's use systemd user units to manage it!

[Unit]
Description=my script description
[Service]
ExecStart=/bin/bash -c "while true do; echo hi; done"
[Install]
WantedBy=default.target

done!
you can now use systemctl --user to manage your daemonized process.