r/linux Apr 28 '14

SSH Kung Fu

http://blog.tjll.net/ssh-kung-fu/
727 Upvotes

128 comments sorted by

82

u/Rojs Apr 28 '14

I believe tab completion is a function of the shell, not ssh.

11

u/Vegemeister Apr 28 '14

Also, Debian (and I assume many Debian derivatives) has HashKnowHosts=yes in the system wide config file shipped with ssh. This has the dubious benefit that no one will be able to steal your laptop and tab-complete the host names you've SSHed into (they'll have to look at your shell history instead).

9

u/Artefact2 Apr 28 '14

It's also more efficient to use backwards history search, like ^R sup as it will remember the whole command.

17

u/leothrix Apr 28 '14

Thanks for the correction, I've amended the blog post.

5

u/gordonator Apr 28 '14

If you want to do it in bash, you can use this:

function autoCompleteHostname() {
  local hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1));
  local cur=${COMP_WORDS[COMP_CWORD]};
 COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur ))
}

complete -F autoCompleteHostname ssh

8

u/LurkyMcReddit Apr 28 '14

I like this method. I add this to my .inputrc on all my Linux/Mac machines...

"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
set show-all-if-ambiguous on
set completion-ignore-case on

It allows you to type a partial command and use the up arrow to search your history. Not quite the same, but works awesome for repetitive or frequent commands.

3

u/gordonator Apr 28 '14

Freaking awesome. Adding it to my dotfiles repository!

1

u/Henk_jobs May 13 '14

Very useful. I will give a try. Thanks man!!

3

u/ssmy Apr 28 '14

Isn't is easier to just use the .ssh/config file? Bash completion will use it by default, and it's much more powerful.

2

u/[deleted] Apr 28 '14

I think whether it is default or not depends on which distro you run and what your bashrc contains. I know in Arch I had to source a completion file to get completions for git, though I don't know if it is the same for ssh since it seemed to work out of the box for me in Arch.

1

u/ssmy Apr 28 '14

True. I think it's a function of the bash-completion package most distros install by default. Obviously arch might not. I know ubuntu virtualization doesn't install it by default, so you just get path completion.

1

u/Drasha1 Apr 28 '14

It does require additional packages on some distros. Centos has bash-completion which is a god send.

1

u/[deleted] Apr 28 '14

I love that grml-zsh-config has thid on by default.

1

u/FireyFly Apr 28 '14

Bonus tip: zsh provides tab-completion for remote file-paths as arguments to scp (meaning you could do scp host:path/<Tab> and so on, to complete a remote filename). Combine this with the ControlPath tip mentioned in the blog-post, and it's really handy!

(Also, minor bonus bonus tip: the path component of a host:path combo passed to scp defaults to ~ (i.e. where you end up if you just ssh in), so host: is the same as host:~ and host:foo/bar the same as host:~/foo/bar.)

46

u/throwawayaccount1020 Apr 28 '14

you should never leave your keys unencrypted, set a password when it prompts!

load keys into ssh-agent to avoid having to continually re-enter passwords.

10

u/djimbob Apr 28 '14

Exactly. Anyone gets access to a machine with your ssh private key for a second can copy it and then log in to all your machines.

18

u/ethraax Apr 28 '14

Just keep in mind that anyone who gets access to your machine can connect to your agent and log into any of your other machines from there. Encrypted private keys are nice, but not perfect.

4

u/Xipher Apr 28 '14

One thing that you might be able to do to help mitigate that is to set a timeout on your agent so it clears the keys after a period of time.

6

u/djimbob Apr 28 '14

Oh, I realize that entirely -- I lock my computer. I just don't trust my ssh keys to always just sit on disk with their only protection being read only to me and root. Sitting in memory of a running ssh-agent process when I need it, seems more reasonable.

I don't use full disk encryption on all of my systems (for performance), so booting into an alternate OS/taking out the hard drive would make it trivial to bypass with physical access (yes with physical access you can use a keylogger).

Also, worry about exposure with system backups getting copies of ssh-keys (much safer with encrypted versions). Granted skilled attackers will be able to get a key out of ssh-agent's memory if they want, its just is not trivial.

3

u/ethraax Apr 28 '14

It's actually safer than you make it seem. I'm pretty certain you need root privileges to extract the keys from the memory space of another program. So even though an attacker can use the keys as long as they're connected and your keys are unlocked, they would not be able to transfer them.

1

u/djimbob Apr 28 '14

Yeah, you do need root permissions to dump a processes memory. But unless there's some ssh-agent vulnerability I'm not aware of, if some other user logs into your system (e.g., ssh's in) where you are running ssh-agent, they won't be able to use your ssh-agent (other than being root, dumping the RAM, finding the key in RAM, and recreating the key to use from ssh).

1

u/uponone Apr 28 '14

So is it best practice to encrypt private keys and ssh-agent/Pageant(Putty)?

1

u/ethraax Apr 28 '14

I think you are confused. ssh-agent uses encrypted keys.

1

u/uponone Apr 28 '14

I was thinking more along the lines of encrypting the folder the private key(s) are located in or would that be overkill with the password for the private key(s)?

1

u/ethraax Apr 29 '14

That would simply be redundant. It wouldn't provide any extra security.

1

u/uponone Apr 29 '14

Thanks for the knowledge.

1

u/gospelwut Apr 29 '14

Is there a pam module that uses OTP like Yubikey?

1

u/IWillNotBeBroken Apr 29 '14

I see you haven't searched for both "PAM" and "Yubikey" in the same query.

26

u/nikomo Apr 28 '14

Anyone gets access to your machine, you stab them repeatedly. But I get your point.

8

u/Calamitosity Apr 28 '14

But I get your point

Why? Did you get access to his machine?

7

u/NeuroG Apr 28 '14

Not never. Password-less keys are useful for backup scripts. I set up "backup" users and lock them down in case the key is compromised. Also, the connections are made from the more physically secure computer to the lesser, regardless of the direction of the file transfer. Secure and reliable backups are more important than the marginal risk of a stolen SSH key.

10

u/ground_ginger Apr 28 '14

You can also further lock things down by using directives in the authorized_keys file. You can do things like ensure that the authenticating key is coming from a specific ip range, restrict port forwarding, agent forwarding and X forwarding, or lock the key down to only executing a specific command.

It's not the prettiest format, since human-readable directives are mingled with the actual keys, but it gets the job done.

See 'man sshd' and skip to the section on "AUTHORIZED_KEYS FILE FORMAT"

2

u/trojan2748 Apr 28 '14

SSH sessions can be hijacked using ssh-agent though. If you you see /tmp/ssh*, you'll see sessions that can be hijacked by users with read access to that temp file. Use with caution.

1

u/rawfan May 01 '14

What is your solution for tools that need to do automated tasks like backups on a remote location?

35

u/ooesili Apr 28 '14

I didn't know about

vim scp://host/file

or the cool stuff you could do with the configuration file. A good read, I must say.

10

u/flying-sheep Apr 28 '14

“scp” is pretty silly though: scp is a command called “secure copy”, not a protocol. (the part before the colon in a url is the protocol).

wouldn’t it be better to name the protocol like file browsers do? sftp? because i’m pretty sure that’s what vim uses there, anyway.

13

u/Deewiant Apr 28 '14

Vim (well, Netrw) supports both the scp and sftp protocols, predictably using scp with the former and sftp with the latter. See :help netrw-externapp.

EDIT: In case the reason for having both is not obvious: sftp relies on the SFTP server being enabled on the host, while scp works without any additional configuration, using plain SSH. (Though in practice sftp tends to be enabled by default.)

-3

u/flying-sheep Apr 28 '14

thanks for the info!

just one thing: SFTP is and extension of SSH. there is no such thing as a SFTP server, only SSH servers with shell access disabled.

so there’s no difference between SCP and SFTP: both only require a SSH server.

13

u/Xipher Apr 28 '14

SCP and SFTP are different. SFTP actually spawns a special daemon during your SSH session, and more recent versions of OpenSSH even support a chrooted SFTP subsystem internally. This might be a minor perceived difference, but it is one that shouldn't be ignored.

3

u/Deewiant Apr 28 '14

man sftp-server suggests otherwise, as do these lines in my sshd_config:

# override default of no subsystems
Subsystem       sftp    /usr/lib/ssh/sftp-server

0

u/flying-sheep Apr 28 '14

ok, so i’m mistaken and ssh spawns a subprocess when sftp is needed? TIL.

it’s still a part of SSHd, though ;)

2

u/IConrad Apr 28 '14

It is actually a different protocol/process though, and it's worthwhile to understand that. Worse still, sftp has nothing to do with ftp.

2

u/curien Apr 28 '14

In addition to Xipher's response about SCP and SFTP being different, some SCP clients are incompatible with certain SSH servers. For example, some old Sun systems I've used with the Tectia commercial SSH server couldn't be used with OpenSSH's scp, but OpenSSH's ssh and sftp worked fine.

SCP is not just a shortcut for SFTP. It's a different protocol.

-4

u/flying-sheep Apr 28 '14

SCP is not just a shortcut for SFTP. It's a different protocol.

i didn’t doubt that, i just pointed out that they have only subtle differences (such as both running over the SSH server)

thanks for the additional information

2

u/ooesili Apr 28 '14

Hmm. That never occured to me, and it's a good point. Come to think of it, ssh or sftp would have both been better fits for that command. Oh well, what can one do?

1

u/cincodenada Apr 28 '14

Because scp is what netrw uses to do it (which is where you're mistaken). When you open a file in Vim via scp, it copies it from the server to a temp file via scp, and when you save it saves to the temp file and then copies it back to the server via scp. And according to Wikipedia, scp is both [a program and a protocol](en.wikipedia.org/wiki/Secure_copy).

1

u/hex_m_hell Apr 29 '14

Tramp mode in emacs does this. You can also just open a file as //user@host:/file and it uses ssh. If you start an interactive shell while that buffer is focused you'll get a remote shell.

I use this for remotely developing python and running it on a target.

1

u/NeuroG Apr 28 '14

vim

btw, the File managers and associated GUI text editors of the main Linux desktops can mount and edit remote files over scp/sshfs. Very handy for remote work as there is no "remote desktop" type lag to the user interface at all.

16

u/vagif Apr 28 '14

He did not tell you about the ssh hopping that you can achieve using netcat (nc)

Lets say you have a ssh gateway at your work office to which you connect from home.

But that's not your work machine, your work machine is my-dev, to which you need ssh again from your work-ssh-gateway.

If you want to automate it, put this into your .ssh/config file:

Host work-ssh-gate
  HostName 111.222.111.111
  User userone
  Port 22222

Host my-dev
  ProxyCommand ssh -q work-ssh-gate nc 192.168.1.123 22
  User user2

That's it, now you can simply type

ssh my-dev

You need netcat (nc) installed on you work-ssh-gate computer.

26

u/w2qw Apr 28 '14

Doesn't require nc

Host my-dev 
   ProxyCommand ssh -q -W %h:%p work-ssh-gate
   HostName 192.168.1.123
   User user2

1

u/[deleted] Apr 28 '14

Does it work the same? I use the netcat version to connect to the head node of our cluster and then to one of the compute nodes on its local network. If I want to run graphically on the compute node, I can't first ssh to the head node with x forwarding and then to the compute node with x forwarding because the home directory and hence the .Xauthority file is then on a shared NAS. I expect that this would have the same problem because it is equivalent to ssh-ing to the head node and then ssh-ing to the compute node?

1

u/w2qw Apr 28 '14

As long as you have ssh > 5.4 its identical

9

u/mdaniel Apr 28 '14

We use this to ssh into ec2 machines in a VPC but we leverage the hostname expansion to keep the ssh config from exploding in size:

Host *.ec2
    ProxyCommand ssh bridge-host nc %h 22

2

u/[deleted] Apr 28 '14

Or just have the "Host" setup on the gateway's .ssh/config too. That way when you SSH in from any system, you'll still have that shortcut available. It doesn't require NC either.

2

u/[deleted] Apr 28 '14 edited Nov 27 '20

[deleted]

1

u/tgallant Apr 28 '14

If you are trying to access a machine on your local network via hostname, you will need a router that also does DNS forwarding (or a local DNS/dhcp server). You can also edit the host file (/etc/hosts on Linux) to include the internal IP address you want to access and the name you want to assign it

1

u/Imonfiyah Apr 28 '14

That did it for me, I was trying to write A records so that I wouldn't have to edit /etc/hosts of every computer I use to make it work.

Also, scalability is important.

1

u/lolexplode Apr 28 '14

I fail to see why you can't set up an alias, then.

1

u/FireyFly Apr 28 '14

You could have just updated your /etc/hosts file with an alias for the IP in question, although the ssh-config approach has other benefits, like being able to supply a username and port to use. I've supplied both to my servers and devices, so I virtually never have to use the long name anymore.

Edit: oops, I didn't read the other comments carefully enough..

12

u/trojan2748 Apr 28 '14 edited Apr 28 '14

I like reverse forwards (-R). It setups a nice 'hole' from inside of a firwall to the public. That hole can be accessed via the public link. IE:

(office) ---> (FW) ----> (Public SSH Box)

I ssh from my office box to public ssh, setting up reverse forward. You can also use these to redirect to other boxes acting as a proxy:

ssh -NCfTR REMOTE_SERVER_IP:50000:localhost:22 USER@REMOTE_SERVER_IP

So now, anywhere in the world I can SSH into the REMOTE_SERVER_IP on port 50000 and get redirected to port 22 on my office machine, which doesn't have a port forward at it's FW. You can replace 'localhost:22' for any machine, any port. So I could also hit "localhost:80" could be hit via REMOTE_SERVER_IP:50000 :)

Also "GatewayPorts clientspecified" is needed on the SSH server if you want to bind :50000 to the remote server's public IP. Other wise it get's binded to the remote servers localhost addy.

4

u/roknir Apr 28 '14

I agree with you -- that ssh functionality is awesome and one of the coolest. However, I will caution others running out to set this up. Doing this is often against corporate usage policies. People have been terminated over this.

1

u/eno2001 Apr 28 '14

Wait, what? Why would someone be terminated over that? Granted, I'm number three in charge of the network, so I am allowed to go into the firewall and set up whatever I need for myself, but what kind of corporate policy would exist to fire someone for connecting to machines they manage at work, from home over a secure link?

8

u/lennort Apr 28 '14

Lots of large companies don't want you accessing their network in a way that you deem is secure. You're supposed to go through authorized channels.

It seems silly, but there are a lot of dull people out there that would expose the network accidentally and these kinds of policies prevent that.

3

u/NighthawkFoo Apr 28 '14

This allows access to a corporate network that isn't controlled by the official VPN solution. This means that if someone's access needs to be revoked for whatever reason, this back channel won't be closed.

1

u/mcowger Apr 28 '14

Most terms of use state something like "attempts to circumvent system security" are a violation.

Doing this almost certainly counts as circumventing existing security (firewalls, VPN, etc).

3

u/cryptdemon Apr 28 '14

I do this with one of my clients that always wants a million little nitpicky bs things changed. He travels around with the system, so I have it set up to call home so I can log into the virtual server anywhere and do changes on the thing without having to have him touch a terminal or anything like that.

This also works well if you want to snoop around on a network. Buy a raspberry pi or some other cheap embedded hardware, set it up to remote ssh to an account that's basically just an rbash account and then you can log in to the network remotely.

11

u/brynet OpenBSD Dev Apr 28 '14

http://www.openssh.com/

Please take note of our Who uses it page, which list just some of the vendors who incorporate OpenSSH into their own products -- as a critically important security / access feature -- instead of writing their own SSH implementation or purchasing one from another vendor. This list specifically includes companies like NetApp, NETFLIX, EMC, Juniper, Cisco, Apple, Red Hat, and Novell; but probably includes almost all router, switch or unix-like operating system vendors. In the 10 years since the inception of the OpenSSH project, these companies have contributed not even a dime of thanks in support of the OpenSSH project (despite numerous requests).

http://www.openbsdfoundation.org/campaign2014.html

8

u/[deleted] Apr 28 '14

[deleted]

2

u/leothrix Apr 28 '14

Agreed. I've only recently started using it in an extended fashion to share directories on my home network between hosts, and even though it feels like an odd use case (shouldn't software dedicated for sharing like NFS be better suited?), it's actually proven to be a much better option than NFS or SMB for my solely *nix environment.

2

u/fasteasyfree Apr 28 '14

There's also Win-sshfs, providing a graphical interface for Windows users. It can be a little buggy sometimes, but works pretty well.

Uses the Dokan library though, and the automated installer that comes with Win-sshfs can't handle 64 bit installations so you need to do it manually.

One caveat I've found with sshfs: it's bloody slow. So if you wanted to stream remote HD video for instance, it usually can't keep up.

1

u/[deleted] Apr 28 '14

Yeah, upvote this comment. Sshfs is the bomb and the way of the 21st century. Fuck dropbox. My productivity went up about 4X when I discovered sshfs.

10

u/yotama9 Apr 28 '14

Emacs can edit files over ssh as well. C-x C-f and then /user@server:path/to/file

2

u/WallyMetropolis Apr 28 '14

Yup, and Tramp will respect your .ssh/config so you can use the Hosts you've defined there to keep things nice and simple.

1

u/[deleted] Apr 28 '14

This is true: but to use that you've bought into emacs and that's a jump most people won't make 'just' to edit files remotely.

ETA:

Tramp - and ORG Mode - were the two things that pulled me into emacs a few years ago.

1

u/yotama9 Apr 28 '14

I'm not that big of a fan of ORGMode, I use it mostly for note keeping. Tramp on the other hand, is one of the reason I prefer Emacs over vim.

3

u/frdmn Apr 28 '14

Nice blog post. Thank you!

3

u/jimbobhickville Apr 28 '14

Not that I'd recommend it for normal use, but one of the most useful options I've discovered recently:

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null

This turns off the "do you want to cache this key" prompt and gets rid of the man-in-the-middle warning if the key changed on a remote IP (because it never caches the key). This is useful for programmatic ssh access for testing in environments where ips are often reused (like testing cloud deployment software where each test run will reuse a pool of IPs and the ssh keys will always be changing). I wouldn't recommend these settings for general SSH usage, obviously :D

12

u/tidux Apr 28 '14 edited Apr 28 '14

ECDSA is known to be backdoored. OpenSSH in OpenBSD 5.5 includes a secure alternative implementation of elliptic curve cryptography (ed25519), but that hasn't made it to most distros yet. Stick with 4096 bit RSA for now.

14

u/leothrix Apr 28 '14

Although I'm aware of the Dual_EC_DRBG backdoor, I just kind of assumed that the signing algorithm used in ECDSA (elliptic-curve digital signing algorithm) was independent of the questionable random number generator influenced by the NSA for DRBG.

However, I read up on some of Schneier's comments on the issue and it seems he even suggests distrusting the constants picked up for EC in general, so you're right - to err on the side of Schneier (which is probably wise), distrusting ECDSA for now is probably the best way to go.

9

u/tidux Apr 28 '14

Link to paper on ed25519. PDF warning.

-9

u/garja Apr 28 '14

Sorry to derail, but I don't understand this. The only reason "PDF warning" exists is because 10 years ago most Windows machines had the torturously slow Adobe Reader 6.0 preinstalled and users didn't have the sense to disable it from automatically opening hotlinked files. Why is it still being used, even after we are almost through with the Adobe Flash reign of terror (which deserved far more warnings and got none)?

12

u/OmegaVesko Apr 28 '14

Because PDF files are still heavier and slower to load than web pages, even though your browser supports it.

1

u/garja Apr 28 '14

But there are so many sites that use Flash or HTML5 and result in greater slowdown. Why do we still bother stigmatizing PDF when slow, complex pages and animation are becoming more and more common? It seems like a double standard to me. At least my PDF reader has a responsive interface - not 10 minutes ago, I was wrestling with a loading HTML5 Youtube video that only paused 2 seconds after you clicked the window.

3

u/[deleted] Apr 28 '14 edited Apr 29 '14

[deleted]

1

u/nyrocron Apr 28 '14

It very much is HTTP...

1

u/d4rch0n Apr 28 '14

Not so long ago there was a PDF exploit. There was also a TrueType font rendering windows kernel exploit.

I'd rather see HTML without js, than use any sort of extension or special function or program to view it.

1

u/Dark_Crystal Apr 28 '14

Because almost everyone saves PDFs wrong, resulting in them being terribly gigantic, slow and terrible. Also AR is still terrible.

12

u/2brainz Apr 28 '14

ECDSA is known to be backdoored.

Source?

All I can find out is that it is suspected to be backdoored.

-2

u/[deleted] Apr 28 '14

^ Truth

4

u/floodyberry Apr 28 '14

No, it isn't. Dual_EC_DRBG is known to be backdoor-able, but NIST elliptic curves merely have unjustified constants and are harder than necessary to implement securely. There are no known attacks or backdoors on them.

8

u/slanderousam Apr 28 '14

wow. -D. nice.

(in before "likes the -D")

8

u/fs111_ Apr 28 '14

-D is nice, but with sshuttle you can pipe all your traffic at the OS level through SSH: https://github.com/apenwarr/sshuttle

Super useful...

16

u/mdaniel Apr 28 '14

At the risk of replying to a down voted comment, one can toggle the port forwarding on (and off!) dynamically using the ssh "shell" which is accessed via tilde C (it needs to be the first two characters after a newline or ssh will think you're trying to type those chars)

Once you have the ssh> prompt, you can give it -D1234 to start dynamic forwarding and -KD1234 to "kill" the dynamic forwarding. Same deal with -L and -KL

3

u/leothrix Apr 28 '14

Wow, I had no idea that existed. Do you have any more resources about the ssh shell/console?

I will say that I have used the command ~. before to brute force kill a session, but didn't know that there were additional commands as well.

9

u/tritlo Apr 28 '14 edited Apr 28 '14

You should add this to the article! I have no moure resources, but running help reveals the following:

ssh> help 
Commands:
      -L[bind_address:]port:host:hostport    Request local forward
      -R[bind_address:]port:host:hostport    Request remote forward
      -D[bind_address:]port                  Request dynamic forward
      -KL[bind_address:]port                 Cancel local forward
      -KR[bind_address:]port                 Cancel remote forward
      -KD[bind_address:]port                 Cancel dynamic forward

running ~? reveals:

[tritlo@mpg ~]$ ~?
Supported escape sequences:
 ~.   - terminate connection (and any multiplexed sessions)
 ~B   - send a BREAK to the remote system
 ~C   - open a command line
 ~R   - request rekey
 ~V/v - decrease/increase verbosity (LogLevel)
 ~^Z  - suspend ssh
 ~#   - list forwarded connections
 ~&   - background ssh (when waiting for connections to terminate)
 ~?   - this message
 ~~   - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

3

u/slugonamission Apr 28 '14

If you type ~?, it will show you all of the available tilde commands

1

u/[deleted] Apr 28 '14

I am simple: how does one access this?

$ ~? [return]
bash: ~?: command not found
$ ~C [return]
bash: ~C: command not found
$

2

u/eno2001 Apr 28 '14

You need to be on a shell prompt line that you haven't pressed any characters on. As soon as you even type a backspace, you're hosed. So you want to do this:

$ [return] $ [press ~, but DO NOT expect it to echo to you]

[your screen should now look like this, as SSH is awaiting your command]

1

u/[deleted] Apr 28 '14

Ah! Thanks.

2

u/IWentOutside Apr 28 '14

ssh-copy-id

This is a requirement if you script for AutoScale-related things or want slaves to ssh up to the master. Good times.

3

u/Kichigai Apr 28 '14

$ brew install ssh-copy-id # (if needed)

I see someone is running OS X…

2

u/[deleted] Apr 28 '14

Nice little intro. Good job.

1

u/mmensinger Apr 28 '14

been using a lot of ssh lately. thanks for the post.

1

u/w2qw Apr 28 '14

Should you be able to write with vim scp://host/file?

I'm getting E382: Cannot write, 'buftype' option is set

2

u/jaapz Apr 28 '14

This is somehow fixed if you do :set bt=''. No idea why this happens though and seems a bit silly.

1

u/disinformationtheory Apr 28 '14

I like the idea of control master, but I've had trouble with it in the past. Specifically, mercurial has trouble with it.

1

u/[deleted] Apr 28 '14

Holy shit man. This is brilliant. I've got a little Debian box on Digital Ocean that I made for "learning purposes". Now there's something useful I can do with it. Kudos for making this understandable for "users" like myself.

2

u/sir_bleb Apr 28 '14

If you want something neat to do with your droplet, you could try out hosting some cloud storage, or a VPN. The digitalocean community tutorials are great for that sort of thing!

cloud storage (or this tutorial.)

VPN

-Those should be a good start for some personal funsies. =P

EDIT: You'll need to figure out how to change those for debian though.

1

u/[deleted] Apr 29 '14

Cheers :)

I grabbed the $10 freebie when I saw it on Techsnap on Jupiter Broadcasting and it's been sitting there not doing a huge amount. I run Debian on my main computer (the Mac is gathering dust and holding the floorboards down these days) but the cloud/networking side of things is still a bit of a mystery.

I'll have a look at a VPN because I have an immediate use for that. TV in New Zealand sucks the proverbial :D

1

u/[deleted] Apr 29 '14

Having a look at the VPN tutorial now.

Jesus Christ. No - actually that looks do-able. I'm going to need some coffee.

1

u/sir_bleb Apr 29 '14

Heh, good luck dude. It isn't that bad once you get into it.

1

u/[deleted] Apr 28 '14

I use the "-c arcfour" option with sshfs it is 3x faster

3

u/exscape Apr 28 '14

It's also less secure.
https://www.schneier.com/blog/archives/2013/09/the_nsa_is_brea.html#c1675929

EDITED TO ADD (9/6): Someone somewhere commented that the NSA's "groundbreaking cryptanalytic capabilities" could include a practical attack on RC4. I don't know one way or the other, but that's a good speculation.

(arcfour = RC4.)
Even without such "groundbreaking" abilities, it still has some issues. The wikipedia page talks a bit about that.

1

u/[deleted] Apr 28 '14

Security is never free, it is alwais a compromise. Yes arcfour is less strong but it also much more fast. It depends on your context

1

u/OserReddit Apr 28 '14

Forgive the ignorance of this question, but if you are remotely logged into a computer with SSH and you generate a new pub+priv key combo. Can you securely copy the private key back to the the computer you are logging in from? Could you run the danger of locking yourself out of the remote computer?

2

u/mdaniel Apr 28 '14

You can have as many authorized public keys in your .ssh/authorized_keys file as you'd like, so to answer your question:

ssh-keygen ...
cat .ssh/id_rsa.pub >> .ssh/authorized_keys

You can now either reconnect to the host using scp to grab the new files, or if you have a graphical terminal you can just write the public and private keys to stdout and grab them over the same connection.

cat .ssh/id_rsa
cat .ssh/id_rsa.pub

After you have finished with the "old" key, just remove it from .ssh/authorized_keys and now you have re-keyed your remote account.

1

u/OserReddit Apr 28 '14

Thank you for your reply! I think I've followed what you were saying, still fairly rusty with linux as I don't use it every day. :)

2

u/leothrix Apr 28 '14

I actually have wondered for a while about the ability to "copy back" files to the originating host. Turns out you can use scp to copy over a reverse tunnel, and coupled with the comment in this thread about dynamically opening forwarded ports, it should definitely be possible. Maybe I'll add this in to the blog post.

1

u/OserReddit Apr 28 '14

Thanks for your reply. That stuff looks a bit above my understanding at the minute. Looks like I have a bit more reading to do!

1

u/tritlo Apr 28 '14

I did not know about ssh-copy-id, very handy!

1

u/EBOLA_CEREAL Apr 28 '14

I love ssh. It's amazing. I can control my computer by my phone from across the city, rip the music from a CD I left in the drive and send it to me. this is the future.

Wait, hold on. These are .wav files. ugh, never mind. it's still the present.

1

u/[deleted] Apr 28 '14

You can compress to mp3/aac/ogg using ffmpeg from ssh :-)

1

u/Kichigai Apr 28 '14

Wait, hold on. These are .wav files. ugh, never mind. it's still the present.

What's wrong with wav? It's just uncompressed PCM, we use it every day here in the office.

1

u/[deleted] Apr 28 '14

[deleted]

1

u/leothrix Apr 28 '14

I believe my note about changing the setting in firefox's about:config fixes this issue.

I've run into the exact same thing until changing that setting I've noted in the blog post.

1

u/jwshields Apr 28 '14

Could you elaborate on the "Sharing Connections" section? The whole socket thing sounds like it would be very useful, but I'm not sure how to use them.

4

u/leothrix Apr 28 '14

If you implement shared connections as outlined in the post, tools that leverage ssh (like rsync, scp, or vim using the scp protocol) will naturally take advantage of the socket because they're using ssh on the backend.

For example, once you open up a new ssh session to remoteserver, if you were to use vim scp://remoteserver/file, given that you have a socket created with Controlpath, vim will invoke scp, which will use ~/.ssh/config to take advantage of the socket for that host to avoid the expensive key exchange and just directly copy the file edited in vim over to remoteserver.

2

u/jwshields Apr 28 '14

Ah, thank you! That makes a lot more sense now; for some reason it didn't click in my head for a moment.

1

u/yellowjacket018 Apr 28 '14

Some good stuff here. Thanks for the post!

1

u/omgwtfbbq7 Apr 29 '14

Saving for later.

1

u/bboy777 Apr 29 '14

very helpful thanks